(load "lab2x.ss")
(define reduce-count
(lambda (exp continuation)
;applies continuation to answer and count
(define loop
(lambda (exp prior-reductions-count)
(reduce-once-appl exp
(lambda (reduced-exp)
(loop reduced-exp
(+ prior-reductions-count
1)))
(lambda ()
(continuation exp
prior-reductions-count)))))
(loop exp 0)))
(define repl
(lambda ()
(display "-> ")
(let ((exp (parse (read))))
(reduce-count
exp
(lambda (answer count)
(display "After ")
(write count)
(display " reductions, reached ")
(write (unparse answer))
(newline))))
(repl)))