Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/*
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