Module: LazyList

Defined in:
lib/lazy_list.rb,
lib/lazy_list/base.rb,
lib/lazy_list/stream.rb

Defined Under Namespace

Classes: Base, Stream

Class Method Summary collapse

Class Method Details

.car(list) ⇒ Object



13
14
15
# File 'lib/lazy_list.rb', line 13

def car(list)
  lambda { list.call( lambda { |a,b| a } ) }
end

.cdr(list) ⇒ Object



9
10
11
# File 'lib/lazy_list.rb', line 9

def cdr(list)
  lambda { list.call( lambda { |a,b| b } ) }
end

.cons(a = nil, b = nil) ⇒ Object



5
6
7
# File 'lib/lazy_list.rb', line 5

def cons(a=nil,b=nil)
  lambda { |c| c.call(a,b) }
end