-
-
Save r3b/f9830e37108c84c46ece to your computer and use it in GitHub Desktop.
A Javascript Y-Combinator, with proper symbols.
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 = function(ƒ) { | |
return (function(x) { | |
return ƒ(function λ(y) { | |
return (x(x))(y); | |
}); | |
}) | |
(function λ(x) { | |
return ƒ(function λ(y) { | |
return (x(x))(y); | |
}); | |
}); | |
}; | |
var fib = Y(function(ƒ) { | |
return (function(n) { | |
return (n == 0 || n == 1) ? n : ƒ(n - 1) + ƒ(n - 2); | |
}); | |
}); | |
fib(20); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Because using the unicode symbols makes me feel like I remotely understand what's going on.