Skip to content

Instantly share code, notes, and snippets.

@niki-timofe
Created July 2, 2019 08:49
Show Gist options
  • Save niki-timofe/ea1fec551950d84df6151a145361beb3 to your computer and use it in GitHub Desktop.
Save niki-timofe/ea1fec551950d84df6151a145361beb3 to your computer and use it in GitHub Desktop.
const factorial = f => n => n === 0 ? 1 : n * f(n - 1);
const fibonacci = f => n => n < 2 ? n : f(n - 1) + f(n - 2);
const Y = f => (g => g(g))(g => (f)(x => g(g)(x)));
Y(factorial)(5);
Y(fibonacci)(5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment