Skip to content

Instantly share code, notes, and snippets.

@Indamix
Created May 3, 2018 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Indamix/241445be3afeeb09bd517e7f734d1f6c to your computer and use it in GitHub Desktop.
Save Indamix/241445be3afeeb09bd517e7f734d1f6c to your computer and use it in GitHub Desktop.
/*
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