Skip to content

Instantly share code, notes, and snippets.

@nodew
Created June 22, 2017 05:39
Show Gist options
  • Save nodew/f6d845a7c098499012526bb91133993a to your computer and use it in GitHub Desktop.
Save nodew/f6d845a7c098499012526bb91133993a to your computer and use it in GitHub Desktop.
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