aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw08.scm13
1 files changed, 6 insertions, 7 deletions
diff --git a/hw08.scm b/hw08.scm
index fe329f2..ca90d5d 100644
--- a/hw08.scm
+++ b/hw08.scm
@@ -209,19 +209,18 @@
(execute-statement false-statement env) ))
; alternate "named" LET syntax
- (while-statement (exp statement) (while-loop exp statement env))
+ (while-statement (exp statement)
+ (let loop ()
+ (if (true-value? (eval-expression exp env))
+ (begin
+ (execute-statement statement env)
+ (loop) ))))
(block-statement (ids statement)
(execute-statement statement
(extend-env ids (map (lambda (id) 0) ids) env) ))
)))
-(define while-loop
- (lambda (exp stmt env)
- (if (true-value? exp)
- (lambda () (execute-statement stmt env) (while-loop exp stmt env))
- (#f))))
-
; expression evaluator
(define eval-expression
(lambda (exp env)