You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sicp-all-tasks/sicp/5_002e48

25 lines
535 B

Exercise 5.48: The compile-and-go
interface implemented in this section is awkward, since the compiler can be
called only once (when the evaluator machine is started). Augment the
compiler-interpreter interface by providing a compile-and-run primitive
that can be called from within the explicit-control evaluator as follows:
;;; EC-Eval input:
(compile-and-run
'(define (factorial n)
(if (= n 1)
1
(* (factorial (- n 1)) n))))
;;; EC-Eval value:
ok
;;; EC-Eval input:
(factorial 5)
;;; EC-Eval value:
120