Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on 3.5.4 Streams and Delayed Evaluation #28

Closed
naosense opened this issue Apr 27, 2019 · 3 comments
Closed

Error on 3.5.4 Streams and Delayed Evaluation #28

naosense opened this issue Apr 27, 2019 · 3 comments

Comments

@naosense
Copy link

(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
Copy link
Contributor

sorawee commented Apr 27, 2019

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)

@sorawee sorawee closed this as completed Apr 27, 2019
@naosense
Copy link
Author

thanks

@io614
Copy link

io614 commented Jun 6, 2021

Alternative solution:

(define (solve f y0 dt)
  (define y (integral-proc (delay (dy)) y0 dt))
  (define (dy) (stream-map f y))
  y)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants