Created
April 13, 2012 19:56
-
-
Save nitin-motiani/2379663 to your computer and use it in GitHub Desktop.
Y combinator in common lisp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(setf Y (lambda (g) | |
(funcall (lambda (f) (lambda (n) (funcall (funcall g (funcall f f)) n))) | |
(lambda (f) (lambda (n) (funcall (funcall g (funcall f f) n))))))) | |
(setf factorial (funcall Y | |
(lambda (f) | |
(lambda (n) | |
(if (< n 2) n | |
(* n (funcall f (- n 1)))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment