Improve 4.8
This commit is contained in:
@@ -197,19 +197,20 @@
|
|||||||
((named-let? exp)
|
((named-let? exp)
|
||||||
(let ((let-name (named-let-var exp))
|
(let ((let-name (named-let-var exp))
|
||||||
(let-variables (named-let-vars exp))
|
(let-variables (named-let-vars exp))
|
||||||
(let-expressions (named-let-exps exp)))
|
(let-expressions (named-let-exps exp))
|
||||||
(cons
|
(let-body (named-let-body exp)))
|
||||||
(list 'define
|
(list
|
||||||
(cons let-name let-variables)
|
'let
|
||||||
(cons 'begin (named-let-body exp)))
|
(cons (list let-name (make-lambda let-variables let-body))
|
||||||
let-expressions)))
|
(named-let-bindings exp))
|
||||||
|
(sequence->exp let-body))))
|
||||||
(else (error "Unsupported let expression -- LET->COMBINATION"))))
|
(else (error "Unsupported let expression -- LET->COMBINATION"))))
|
||||||
|
|
||||||
(assert (let->combination '(let ((a 3) (b 4)) (* 3 a b)))
|
(assert (let->combination '(let ((a 3) (b 4)) (* 3 a b)))
|
||||||
'((lambda (a b) (* 3 a b)) 3 4))
|
'((lambda (a b) (* 3 a b)) 3 4))
|
||||||
|
|
||||||
(assert (let->combination '(let fib-iter ((a 1)) (fib-iter (+ a 1))))
|
(assert (let->combination '(let fib-iter ((a 1)) (fib-iter (+ a 1)) 3))
|
||||||
'((define (fib-iter a) (begin (fib-iter (+ a 1)))) 1))
|
'(let ((fib-iter (lambda (a) (fib-iter (+ a 1)) 3)) (a 1)) (begin (fib-iter (+ a 1)) 3)))
|
||||||
|
|
||||||
(display "\nex-4.9 - iteration-constructs\n")
|
(display "\nex-4.9 - iteration-constructs\n")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user