From a7bf1376fa635c6868752c6458442aef5da63327 Mon Sep 17 00:00:00 2001 From: Ramakrishnan Muthukrishnan Date: Sat, 31 Dec 2011 23:27:25 +0530 Subject: [PATCH] bug fix for let* to handle the body properly --- src/sicp/metacircular2.rkt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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)])) -- 2.37.2