Created
May 3, 2018 13:02
-
-
Save Indamix/241445be3afeeb09bd517e7f734d1f6c to your computer and use it in GitHub Desktop.
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
/* | |
const Y = (f) => | |
( x => f(v => x(x)(v)) )( | |
x => f(v => x(x)(v)) | |
); | |
*/ | |
const Y = f => { | |
const something = x => f(v => x(x)(v)); | |
return something(something); | |
}; | |
const factorial = Y( | |
fac => | |
n => | |
n === 0 | |
? 1 | |
: n * fac(n - 1) | |
); | |
console.log(factorial(5)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment