read

(define zero (lambda (f) (lambda (x) x)))
(define (add
-1 n)
(lambda (f) (lambda (x) (f ((n f) x)))))
(define one (lambda (f) (lambda (x) (f x))))
(define (plus a b) (lambda (f) (lambda (x) ((b f) ((a f) x)))))

(define (test n int)
(equal
? int ((n (lambda (x) (+ x 1))) 0)))

' test result
> (test zero 0)
#t
> (test one 1)
#t
> (test (add-1 zero) 1)
#t
> (test (plus zero zero) 0)
#t
> (test (plus zero one) 1)
#t
> (test (plus one one) 2)
#t
> (test (plus one (plus one one)) 3)
#t
>

Blog Logo

Ki Sung Bae


Published

Image

Gsong's Blog

Developer + Entrepreneur = Entreveloper

Back to Overview