Exercises: 1. Sometimes it'd be useful to return the value of the first expression in a sequence instead of the last. For example, instead of: (define x 0) (let ((temp x)) (set! x (+ x 1)) temp) we could write instead: (define x 0) (return-first x (set! x (+ x 1)) ) Modify the metacircular evaluator to recognize a new special form, RETURN-FIRST. Like BEGIN, RETURN-FIRST should evaluate expressions in left-to-right order, but it should return the value of the first expression instead of the last. 2. Modify the metacircular evaluator so that the symbol *result* returns the last value returned to the user. For example: MCE> (+ 1 2) 3 MCE> *result* 3 MCE> (/ *result* 2) 1.5 MCE> *result* 1.5 3. Modify the metacircular evaluator so that procedures can use dotted-tail notation to accept an optional number of arguments. Test your changes. Correctly implemented changes should allow your modified evaluator to handle each of the following: (define (foo . args) (list args)) (define (foo x . args) (list x args)) (define foo (lambda args (list args))) (define foo (lambda (x . args) (list x args))) 4. Writing procedures that use dotted-tail notation can be a bit cumbersome without an APPLY procedure. Modify the metacircular evaluator so that it has a primitive procedure APPLY. Recall that APPLY takes a procedure and a list as arguments. For example: MCE> (apply + '(1 2 3 4 5)) returns the same result as if we had typed (+ 1 2 3 4 5), or 15. 5. Modify the metacircular evaluator so that the numbers 1 and 0 denote boolean truth values rather than #t and #f. For example: MCE> (list? '(a b c)) 1 MCE> (list? 'a) 0 *** 6. WARNING: DO NOT ATTEMPT THE FOLLOWING PROBLEM UNLESS YOU ARE CONFIDENT IN YOUR UNDERSTANDING OF THE METACIRCULAR EVALUATOR. IF THE FOLLOWING PROBLEM CONFUSES YOU, PRETEND YOU NEVER SAW IT. Suppose we entered the following expression from within the metacircular evaluator: MCE> (define square (list 'procedure '(x) '((* x x)) (car (cdr (cdr (cdr (lambda () 'do-nothing) )))) )) MCE> (square 10) Perhaps surprisingly, the textbook's implementation of the metacircular evaluator does not return any errors and actually computes the square of 10. (This is a BUG, not a feature!) Briefly explain why this bug occurs. What would you need to do to correct this problem?