assgn7.scm must be loadable into Scheme and procedures must pass tests of correctness.
- Starting with continuation-passing interpreter interp4-1cps.scm, implement and test
while-do. Study implementations ofvarassign-expandbegin-expto get the idea.Recall the grammar
and code(expression ("while" expression "do" expression) while-do-exp)where(while-do-exp (test exp) (eval-while-do test exp env))Or see interp3-7loop.scm.(define eval-while-do (lambda (test exp env) (if (true-value? (eval-expression test env)) (begin (eval-expression exp env) (eval-while-do test exp env)) 1)))This has to be translated to CPS and a
while-do-contcontinuation has to be constructed.
- Examine and experiment with Scheme.java, a call-by-value interpreter in Java that parses and evaluates list syntax. Compile with
and run withjavac Scheme.javaorjava Schemejava Scheme file.scm- Complete and test definition of
Ifclass.- Modify
to add parameters lo and hi to index, solet index = proc (n, l) letrec loop(l) = if null?(l) then raise sub1(0) else if equal?(n, car(l)) then 0 else add1((loop cdr(l))) in try (loop l) handle proc (x) x in begin print((index 1 list(2, 3, 4))); print((index 3 list(2, 3, 4))); (index 4 list(2, 3, 4)) endHave your expression print the results of several calls, which test index in all cases. Use interp4-4exc.scm(index n lst lo hi) => index of n in lst if n occurs in pos n to m else -1