Skip to content

Instantly share code, notes, and snippets.

@tenderlove
Last active Aug 29, 2015
Embed
What would you like to do?
cons = lambda { |x,y| lambda { |m| m.call x, y } }
car = lambda { |z| z.call lambda { |p, q| p } }
cdr = lambda { |z| z.call lambda { |p, q| q } }
each = lambda { |list, cb|
break unless list
cb.(car.(list))
each.(cdr.(list), cb)
}
list = cons.(1, cons.(2, cons.(3, nil)))
p list
each.(list, lambda { |item| p item })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment