Implement 5.49
This commit is contained in:
24
ex-5_50-52.scm
Normal file
24
ex-5_50-52.scm
Normal file
@@ -0,0 +1,24 @@
|
||||
(load "shared/util")
|
||||
(load "shared/sicp-load-eceval-compiler")
|
||||
(load "shared/sicp-compiler")
|
||||
|
||||
(display "\nex-5.50 - compile-metacircular-evaluator\n")
|
||||
|
||||
; Exercise 5.50. Use the compiler to compile the metacircular evaluator of
|
||||
; section 4.1 and run this program using the register-machine simulator. (To
|
||||
; compile more than one definition at a time, you can package the definitions
|
||||
; in a begin.) The resulting interpreter will run very slowly because of the
|
||||
; multiple levels of interpretation, but getting all the details to work is an
|
||||
; instructive exercise.
|
||||
|
||||
(compile-and-go
|
||||
'(begin
|
||||
(define (factorial n)
|
||||
(if (= n 1)
|
||||
1
|
||||
(* (factorial (- n 1)) n)))
|
||||
(factorial 10)))
|
||||
|
||||
(display "\nex-5.51\n")
|
||||
|
||||
(display "\nex-5.52\n")
|
||||
Reference in New Issue
Block a user