-
-
Save xgrommx/c8835bff8197a93c838e 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
let Ym = (f, x = {}) => (...args) => { | |
var y = JSON.stringify(args) | |
return x[y] || (x[y] = f(z => Ym(f, x)(z)).apply(this, args)) | |
} | |
let fib = Ym(f => n => n === 0 ? n : n === 1 ? n : f(n - 1) + f(n - 2)) | |
console.log('fib(1000)', fib(1000)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment