2015/12/19
SICP 問題 4.09
;; iteratorの実装
;; whileの使用例
(while (< i 10)
(begin (display i)
(newline)
(set! i (+ i 1))))
(let while ()
(if (< i 10)
(begin
(begin (display i)
(newline)
(set! i (+ i 1)))
(while))))
;; 破壊的です.
(define (while? exp) (tagged-list? exp 'while))
(define (while-predicate exp) (cadr exp))
(define (while-body exp) (caddr exp))
(define (while->let exp)
(make-named-let 'my-while '()
(make-if (while-predicate exp)
(meke-begin
(list (while-body exp)
'(my-while)))
'())))