Lab 14

Here’s a tiny expression language of numbers and addition:

(define-type AE
  [num (n number?)]
  [add (lhs AE?) (rhs AE?)])
  1. Develop interp, that maps an AE to a number by evaluating it in the expected way.

  2. CPS-transform this to produce interp/k.

  3. Add an abort variant to the AE. The abort form should have a single subexpression, and should halt the computation, returning the result of evaluating its subexpression. Update interp so that it uses call/cc to abort the computation on a use of abort

  4. Update interp/k so that when it encounters an abort, it halts without doing further computation. Note that since interp/k is written in CPS, no call/cc is required here!

  5. Additional practice on CPSing, if desired: develop my-foldl, that produces the same result and has the same contract as foldl, then CPS-transform it to obtain my-foldl/k.