PLI Tutorial 10 Scheme interpretation and compilation (Draft) Some of these questions are revision. 1. Write a Scheme function (subst exp old new) to replace every occurrence of the symbol old in the list exp by the value new. The function should return a new list and not change the old list. E.g., (subst '(a (b a c) d) 'a '(e f)) ==> (((e f) (b (e f) d) 2. Add let- and let*- expressions to the final Scheme interpreter, eval6.s. Note that let-expressions are shorthand for procedure application: (let ((x1 e1) ... (xm em)) exp1 ... expn) ==> ((lambda (x1 ... xm) exp1 ... expn) e1 ... em) 3. Add (begin exp1 ... expn), n >=0, to the final Scheme interpreter, eval6.s. This form evaluates each expi in turn and returns the value of the final one. 4. Add do-expressions to the final Scheme interpreter, eval6.s. The syntax of a do-expression, a generalised for-loop, is as follows: (do ((v1 init1 incr1) ... (vm initm incrm)) ; m >= 0 (termination-condition val1 ... valn) ; valn is returned, n >= 0 exp1 ... expp) ; p >= 0 See the function (factors n) in the examples file for examples. Hint: Note that do-expressions are shorthand for tail-recursive procedure application: (do (...) (...) exp1 ... expp) ==> (define (newproc v1 ... vm) (if termination-condition (begin val1 ... valn) (begin exp1 ... expp (newproc incr1 ... incrm)))) (newproc init1 ... initm) 5. Construct an example of a circular environment. I need to write some questions about continuations and compilation...