CS 491 (Spring 2002) Homework 1.5
-
Using the lambda calculus interpreter found here, and using the given definitions of
true, false, succ, pred, nil?,
etc., use the Y-combinator to write a lambda expression,
equals, with natural number argument, x, which returns a
lambda expression with natural number argument, y, which
returns true, if x=y, and returns false
otherwise. For example,
> true
(lambda (x) (lambda (y) x))
> false
(lambda (x) (lambda (y) y))
> (define one (reduce `(,succ ,nil)))
> (define two (reduce `(,succ ,one)))
> (reduce '((,equals ,one) ,one))
(lambda (x) (lambda (y) x))
> (reduce '((,equals ,one) ,two))
(lambda (x) (lambda (y) y))
>
- Use the Y-combinator to write a lambda expression, fact,
with natural number argument, x, which returns x!. For example,
> (define answer (reduce '(,fact ,three)))
> (reduce '((,equals ,answer) ,six))
(lambda (x) (lambda (y) x))
>