Skip to content

Instantly share code, notes, and snippets.

@buunguyen
Created September 21, 2012 01:29
Show Gist options
  • Save buunguyen/3759287 to your computer and use it in GitHub Desktop.
Save buunguyen/3759287 to your computer and use it in GitHub Desktop.
Y-Combinator in Bike
var Y = func(h) {
return func(f) {
f(f)
}(func(f) {
h(func(n) { f(f)(n) })
});
};
var fact = Y(func(recur) {
return func(n) {
n == 1 ? 1 : n * recur(n-1)
};
});
println(fact(5));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment