Created
September 21, 2012 01:29
-
-
Save buunguyen/3759287 to your computer and use it in GitHub Desktop.
Y-Combinator in Bike
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
var Y = func(h) { | |
return func(f) { | |
f(f) | |
}(func(f) { | |
h(func(n) { f(f)(n) }) | |
}); | |
}; | |
var fact = Y(func(recur) { | |
return func(n) { | |
n == 1 ? 1 : n * recur(n-1) | |
}; | |
}); | |
println(fact(5)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment