Created
August 25, 2016 09:23
-
-
Save anonymous/100441ffa8a88354ce6007e01371bc86 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) }.inject(&:+) | |
end | |
).call([1,2,3]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment