Created
June 22, 2017 05:39
-
-
Save nodew/f6d845a7c098499012526bb91133993a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const Y = function(F) { | |
return (function (h) { | |
return h(h) | |
})(function(h) { | |
return F(function() { | |
return h(h).apply(this, arguments) | |
}) | |
}) | |
} | |
const fib = Y(function(f) { | |
return function(i) { | |
if (i === 0 || i === 1) { | |
return 1 | |
} | |
return f(i - 1) + f(i - 2) | |
} | |
}) | |
console.log(fib) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment