Author: | Arrogant |
---|---|
Mode: | scheme |
Date: | Tue, 9 Nov 2010 06:45:32 |
(require (lib "defmacro.ss")) (define y-combinator (λ (x) ((λ (p) (x (λ (n) ((p p) n)))) (λ (p) (x (λ (n) ((p p) n))))))) (define-macro y-lambda (λ (self proc) (let ((self-symbol (car self))) `(y-combinator (λ (,self-symbol) ,proc))))) ((y-lambda (self) (λ (n) (if (zero? n) 1 (* n (self (- n 1)))))) 5) ; 120