Observe that the language in this is somewhat different than in lab 1,
so you need different parse and unparse
procedures. The versions on page 85 should work.
reduce-once-appl fails to reduce is an answer. In most
cases this is the same as the book's definition, but they differ on
some irreducible applications such as (x x).
reduce-once-appl that is in
the book. Instead, use my version, which is linked onto the web copy of
this lab handout. Note that my version makes no use of the procedure called
answer?. Nor should you: don't type it in or any variant
of it. Anywhere you might think it is useful, you can instead use
reduce-once-appl with appropriate success and failure
continuations.
> (reduce-history '((lambda (x) (x ((lambda (x) y) z))) w) 5) (((lambda (x) (x ((lambda (x) y) z))) w) (w ((lambda (x) y) z)) (w y)) > (reduce-history '((lambda (x) (x x)) (lambda (x) (x x))) 3) (((lambda (x) (x x)) (lambda (x) (x x))) ((lambda (x) (x x)) (lambda (x) (x x))) ((lambda (x) (x x)) (lambda (x) (x x))) ((lambda (x) (x x)) (lambda (x) (x x))))
reduce-history to reduce-history-appl and
reduce* to reduce*-appl and make
corresponding reduce-history-leftmost and
reduce*-leftmost procedures. Rather than duplicating
code between the applicative-order and leftmost versions, you should
use a generalized or higher-order procedure to capture the commonality.