|
I was thinking of this
(define (make_increment)
(let ((history '()))
(lambda (n)
(if (integer? n)
(begin
(set! history (append history (list n)))
(+ n 1))
history))))
(define increment (make_increment))
But two brilliant people saw the more elegant form:
(define increment
(let ((history '()))
(lambda (n)
(if (integer? n)
(begin
(set! history (append history (list n)))
(+ n 1))
history))))
It makes perfect logical sense, and it works (I tested it). I don't remember seeing this form in the text, but maybe I overlooked it.
|