Implement till 5.29 and separate regular and lazy eceval

This commit is contained in:
2021-04-10 11:22:42 -04:00
parent a7dfeac4ba
commit 59b58cfb9a
4 changed files with 444 additions and 413 deletions

View File

@@ -1,6 +1,7 @@
(load "util.scm")
(load "misc/sicp-regsim.scm")
(load "misc/sicp-eceval.scm")
(load "misc/sicp-eceval-lazy.scm")
(define the-global-environment (setup-environment))
(set-register-contents! eceval 'exp '(if false 1 2))
@@ -137,9 +138,34 @@
; | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
; |----|----|----|----|----|----|----|----|----|----|
; | | | | | | | | | | | depth
; | | | | | | | | | | | push count
; | 8| 13| 18| 23| 28| 33| 38| 43| 48| 53| depth
; | 22| 78| 134| 246| 414| 694|1142|1870|3046|4950| push count
(display "\nex-5.30\n")
; a.
; depth = 3 + 5 * n
; push-count =
; b.
; S(n) := push-count for n
; S(n) = S(n - 2) + S(n - 1) + k
; k = 34 ; calculated from table
; S(n) = a * Fib(n + 1) + b
; a = 56, b = -34 ; calculated on paper
; S(7) = a * Fib(8) + b
; = 56 * 21 - 34
; = 1142
(display "\nex-5.30 - error-handling\n")
(set-register-contents! eceval 'exp
'(begin
(define (foo x) x)
(foo a)))
(start eceval)
(newline)
(assert (get-register-contents eceval 'val) 'unbound-variable-error))
(newline)
;; CONTINUE HERE