$ cd ~

SICP Exercise 2.6

zero and add-1 are defined as:

(define zero (lambda (f) (lambda (x) x)))

(define (add-1 n)
	(lambda (f) (lambda (x) (f ((n f) x)))))

With these definitions we can calculate one and two.

one is add-1 applied to zero:

> (add-1 zero)
> (lambda (f) (lambda (x) (f ((zero f) x))))

As zero is an identity function (i.e. (f x) returns x) one reduces to:

> (lambda (f) (lambda (x) (f x)))

two is add-1 applied to one:

> (add-1 one)
> (lambda (f) (lambda (x) (f (((lambda (a) (lambda (b) (a b))) f) x))))
> (lambda (f) (lambda (x) (f ((lambda (b) (f b)) x))))
> (lambda (f) (lambda (x) (f (f x))))

two reduces to:

(define two (lambda (f) (lambda (x) (f (f x)))))