Last active
August 29, 2015 14:16
-
-
Save ay/2a0ba5108a69139eef24 to your computer and use it in GitHub Desktop.
Factorial with Y combinator
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
(define (f partial) | |
(lambda (n) | |
(cond ((= n 0) 1) | |
(else (* n (partial (- n 1))))))) | |
(define (y f) | |
((lambda (g) | |
(g g)) (lambda (g) (lambda (n) ((f (g g)) n))))) | |
(define fact (y f)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment