lisp

solutions to Lisp in Small Pieces
Log | Files | Refs | Feed

commit 5ffe3eaab1ce29dd78eb05d6b873750f26acdf8e
parent 2ee26add32d22f2ca72eda8565b25f34d4b91b0f
Author: Jenny Doe <tng@soykaf.me>
Date:   Tue,  8 Jan 2019 18:35:16 +0100

Removed unnecessary computation

Diffstat:
Mchapter1/s.procedures_1-4.scm | 14++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/chapter1/s.procedures_1-4.scm b/chapter1/s.procedures_1-4.scm @@ -1,14 +1,12 @@ (define (make-function bound-names body env) (lambda (values current.env) - (let ((old-bindings - (map (lambda (bound-name value) - (let ((old (getprop 'apval bound-name '()))) - (putprop 'apval bound-name (cons value old)) - bound-name)) - bound-names values))) (begin + (for-each (lambda (bound-name value) + (let ((old (getprop 'apval bound-name '()))) + (putprop 'apval bound-name (cons value old)))) + bound-names values) (let ((res (eprogn (list body) current.env))) (for-each (lambda (x) (putprop 'apval x (cdr (getprop 'apval x)))) - old-bindings) - res))))) + bound-names) + res))))