Skip to content

Instantly share code, notes, and snippets.

@jiacai2050
Last active February 25, 2016 13:48
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 jiacai2050/ef30ba3605a6ae256062 to your computer and use it in GitHub Desktop.
Save jiacai2050/ef30ba3605a6ae256062 to your computer and use it in GitHub Desktop.
var Y = function(f) {
return function(x) {
return x(x)
}(function (x) {
return f(function(y) {
return x(x)(y)
})
})
}
var F = function(g) {
return function(n) {
if (n == 0) {
return 1;
} else {
return n * g(n-1);
}
}
}
Y(F)(5)
(define F
(lambda (g)
(lambda (n)
(if (= n 0)
1
(* n (g (- n 1)))))))
(define Y
(lambda (f)
((lambda (x) (x x))
(lambda (x) (f (lambda (y) ((x x) y)))))))
((Y F) 5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment