Skip to content

Instantly share code, notes, and snippets.

@rewinfrey
Created March 2, 2015 07:37
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 rewinfrey/20b871313c00b69867a9 to your computer and use it in GitHub Desktop.
Save rewinfrey/20b871313c00b69867a9 to your computer and use it in GitHub Desktop.
sample factorial y combinator in Ruby
result = -> (builder, number) { builder.call(builder, number) }.call(
-> (recurse, number) {
return 1 if number == 0
return number * recurse.call(recurse, number - 1)
},
5
)
result # => 120
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment