Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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