-
-
Save kmicinski/a383dadbb3e8fb0547dd to your computer and use it in GitHub Desktop.
The Y Combinator in Ruby
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
class Proc | |
def y | |
lambda { |x| call(y).call(x)} | |
end | |
end | |
(lambda { |f| lambda { |x| if x == 0 then 1 else x * f.call(x-1) end } }).y.call(12) | |
# 479001600 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment