You may work singly or in pairs on this assignment.
(25 points) EOPL, Exercises 3.11, 3.12, and 3.17 (no need to answer the testing question).
Note that the 3.7 portion (mentioned in 3.12 and 3.17) is really from Lab 6, but you'll need them to adequately test your answers.
(15 points) EOPL, Exercise 3.13.
(15 points) EOPL, Exercise 3.18.
As an example of its usage, the following code should evaluate
to 68, because 5 + 7 9 = 68:
unpack a b c d = cons(5,cdr(list(6,7,8,9))) in +(a,*(b,d))In contrast, the following code should result in an error:
unpack a b c d = cons(5,cdr(list(6,7,8,9,10))) in +(a,*(b,d))
(15 points) EOPL, Exercise 3.20.
(20 points) EOPL, Exercise 3.29.
At a minimum, the entry message should include both the formal and actual parameters, and the exit message should include the result. As an example, the result of evaluating
let tester = traceproc (x,y) *(v,+(x,y)) in (tester 3 4)should look something like the following:
--> let tester = traceproc (x,y) *(v,+(x,y)) in (tester 3 4) entering procedure with parameters: x=3 y=4 leaving procedure, with result: 35 35 -->Note that the second 35 is the value of the entire expression.
To state the obvious, unpack is a variation
of let. First, understand what is going on with
let, then understand what is different
about unpack, and then, and only then, think
about coding things.
For the traceproc problem, add a new record
structure to the procval datatype for this new
sort of procedure.
Also for the traceproc problem, your messages
do not need to be sophisticated or pretty. As a very simple
procedure to write both a message and a Scheme value, you can
use the following (or design your own):
(define myprint
(lambda (str obj)
(begin
(display str)
(display obj))))
You may find Scheme's begin construct (see Dybvig, Section 5.2) useful to sequence a series of expressions, as in myprint above.