Skip to content

Instantly share code, notes, and snippets.

Created August 25, 2016 09:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/ce1f6f96ab48c15b7d7c48629db21dd1 to your computer and use it in GitHub Desktop.
Save anonymous/ce1f6f96ab48c15b7d7c48629db21dd1 to your computer and use it in GitHub Desktop.
lambda do |fn|
lambda { |x| x.call(x) }.call(
lambda do |myself|
lambda do |arg|
fn.call(arg, myself.call(myself))
end
end
)
end.call(
# The lambda we wish to make recursive
lambda do |arg, recurse|
arg.kind_of?(Numeric) ? arg : arg.map { |item| recurse.call(item) }.inj\
ect(&:+)
end
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment