Implement 5.49

This commit is contained in:
2021-05-01 18:30:24 -04:00
parent 363f49d434
commit 2265a4afa5
3 changed files with 38 additions and 8 deletions

24
ex-5_50-52.scm Normal file
View 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")