Read Chapter 5 in the EOPL book.

The directory /cs/classes/cis624/www/coreScheme/ contains the beginnings of a Scheme interpreter written in Java. For example,

/cs/classes/cis624/www/coreScheme > java schemeInterp Java> 3 ==> 3 Java> + ==> + Java> #t ==> #t Java> (if (if #t #f #t) 33 99) ==> 99 Java> (+ 2 (* 4 2)) ==> 10 Java> (= 4 5) ==> #f Java> (if (= 4 5) (+ 2 1) (- 2 1)) ==> 1Complete the interpreter by adding clauses for the following Scheme expressions:

- lambda expressions,
- general applications,
- let expressions,
- set! expressions,
- letrec expressions.

Java> (let ((x 3)) (let ((f (lambda () x)) (g (lambda () (set! x 10)))) (let ((d (g))) (f)))) ==> 10 Java> (letrec ((fact (lambda (n) (if (= n 0) 1 (* n (fact (- n 1))))))) (fact 5)) ==> 120

Page visited times since November 18, 1996.

sabry@cs.uoregon.edu