Skip to content

Instantly share code, notes, and snippets.

@nitin-motiani
Created April 13, 2012 19:56
Show Gist options
  • Save nitin-motiani/2379663 to your computer and use it in GitHub Desktop.
Save nitin-motiani/2379663 to your computer and use it in GitHub Desktop.
Y combinator in common lisp
(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