Permalink
Browse files

added ycombinator.scm

  • Loading branch information...
Ezra Zygmuntowicz
Ezra Zygmuntowicz committed Nov 24, 2010
1 parent c0b4bb4 commit 27584a1c98acb9c0fd55b425385542fd38096b2c
Showing with 19 additions and 0 deletions.
  1. +19 −0 examples/ycombinator.scm
View
@@ -0,0 +1,19 @@
+; The applicative-order Y combinator
+;
+(define Y
+ (lambda (X)
+ ((lambda (procedure)
+ (X (lambda (arg) ((procedure procedure) arg))))
+ (lambda (procedure)
+ (X (lambda (arg) ((procedure procedure) arg)))))))
+
+(define F*
+ (lambda (func-arg)
+ (lambda (n)
+ (if (zero? n)
+ 1
+ (* n (func-arg (- n 1)))))))
+
+(define fact (Y F*))
+(write (fact 8))
+

0 comments on commit 27584a1

Please sign in to comment.