Created
September 12, 2019 15:46
-
-
Save ryohji/036ebe410fdf46f9cfa5cdc6441ad199 to your computer and use it in GitHub Desktop.
Z combinator
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 Z = f => (x => f(y => x(x)(y)))(x => f(y => x(x)(y))); | |
const fact = Z(f => x => x != 0 ? x * f(x-1) : 1); | |
fact(5); // => 120 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment