Last active
February 20, 2019 14:42
-
-
Save shellsong/8c1caf18eb11052f82c4 to your computer and use it in GitHub Desktop.
YCombinator
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 = require('./Y') | |
exports.fibonacci = Y((f) => (n) => n === 0 || n === 1 ? 1 : f(n - 1) + f(n - 2)) | |
exports.factorial = Y((f) => (n) => n <= 0 ? 0 : (n === 1 ? 1 : n * f(n - 1))) |
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
module.exports = (le) => ((f) => f(f))((f) => le((x) => (f(f))(x))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment