From: Ramakrishnan Muthukrishnan Date: Sat, 31 Dec 2011 17:57:25 +0000 (+0530) Subject: bug fix for let* to handle the body properly X-Git-Url: https://git.rkrishnan.org/pf/content/en/components/com_hotproperty/%3C?a=commitdiff_plain;h=a7bf1376fa635c6868752c6458442aef5da63327;p=sicp.git bug fix for let* to handle the body properly --- diff --git a/src/sicp/metacircular2.rkt b/src/sicp/metacircular2.rkt index f08b5a1..a2dd8d4 100644 --- a/src/sicp/metacircular2.rkt +++ b/src/sicp/metacircular2.rkt @@ -176,9 +176,9 @@ ;; let* (define (let*->nested-lets lexpr) (match lexpr - [`(let* (,first-binding ,rest-bindings ...) ,body) - `(let (,first-binding) ,(let*->nested-lets `(let* ,rest-bindings ,body)))] - [`(let* () ,body) body])) + [`(let* (,first-binding ,rest-bindings ...) ,body ..1) + `(let (,first-binding) ,(let*->nested-lets `(let* ,rest-bindings ,@body)))] + [`(let* () ,body ..1) `(let () ,@body)])) ;; internal definitions (define (scan-out-definitions body) @@ -191,7 +191,7 @@ ;; eval (define (eval exp env) - ;; (display (format "~s~%" exp)) + (display (format "~s~%" exp)) (match exp [(? self-evaluating? exp) exp] [(? variable? exp) (lookup-variable-value exp env)] @@ -204,7 +204,7 @@ [`(begin ,exp ...) (eval-sequence exp env)] [`(cond ,clauses ...) (eval (cond->if clauses) env)] [`(let ,bindings ,body ..1) (eval (let->combination exp) env)] - [`(let* ,bindings ,body) (eval (let*->nested-lets exp) env)] + [`(let* ,bindings ,body ..1) (eval (let*->nested-lets exp) env)] [(list f x ...) (apply (eval f env) (list-of-values x env))] [_ (error "unable to evaluate expression -- EVAL " exp)]))