Error on 3.5.4 Streams and Delayed Evaluation
naosense opened this issue · 3 comments
naosense commented
(define (solve f y0 dt)
(define y (integral (delay dy) y0 dt))
(define dy (stream-map f y))
y)print y: undefined; cannot use before initialization
sorawee commented
Please see Footnote 71 in the book, which states that you should see Section 4.1.6 and perhaps Exercise 4.18 :)
If you really want it to work without code transformation, try:
(define (solve f y0 dt)
(define y (integral (delay (force dy)) y0 dt))
(define dy (delay (stream-map f y)))
y)naosense commented
thanks
io614 commented
Alternative solution:
(define (solve f y0 dt)
(define y (integral-proc (delay (dy)) y0 dt))
(define (dy) (stream-map f y))
y)