CS37 -- Laboratory 10

Due: Thursday, Nov. 12 by 11:59 pm

Email solutions to cfk@cs.swarthmore.edu by Thursday, Nov 12, 11:59 pm. Provide code and evidence of testing. For the code part of the second problem, just provide parts that are different from the code provided for the first problem.

  1. page 380, ex 4.13
  2. Implement quasiquote and unquote so that they work in the driver-loop and mini-eval that you have at the end of clab29. (You can begin now. If you do it correctly and it works in what we had at the end of clab27, it should work in what we have at the end of clab29). I want to see it as an extension of the clab29 material.

    Here are a few brief details about quasiquote and unquote:

    1. The syntax is of quasiquote is (quasiquote expr) which can be abbreviated as `expr. Note that is a back apostrophe, not an ordinary apostrophe.
    2. The syntax is of unquote is (unquote expr) which can be abbreviated as ,expr.
    3. (unquote expr) can only appear inside of a quasiquoted expression.
    4. If the quasiquoted expression contains no unquoted sub-expressions, then (quasiquote expr) is equivalent to (quote expr).
    5. If an (unquote expr) appears in a quasiquoted expression, then (unquote expr) is replaced by the evaluated expression expr.
    6. If a (quasiquote expr) appears in a quasiquoted expression, it is unchanged.

    I want your tests to work in your driver-loop for your mini-eval. Here are some interactions in drScheme (not mini-eval):

    > (define a 3)
    > (define b 4)
    > ,a                  ; rule 3 
    unquote: not in quasiquote in: (unquote b)
    > '(+ a b)
    (+ a b)
    > `(+ a b)            ; rule 4 
    (+ a b)
    > `(+ ,a ,b)          ; rule 5 
    (+ 3 4)
    > `(+ `(+ ,a ,b) ,b)  ; rule 6
    (+ `(+ ,a ,b) 4)
    > `,`,`,a
    3
    
    Feel free to try other combinations to make sure you understand how quasiquote and unquote work.


As of 1 Oct, the final exam for CS37 has been scheduled by the registrar for Wednesday 12/16/2009, 9:00am-12:00pm in SC240. Plan to attend.