[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange behavior with delayed objects

From: user8472
Subject: Re: Strange behavior with delayed objects
Date: Fri, 14 May 2010 14:53:27 -0700 (PDT)

OK, I have found a solution. The point is that in section 4.2.2 of R5RS it is
explicitly stated that mutually recursive defines must not refer to those
variables. The solution is thus to wrap the defines in (lambda () ...)s.

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

(debug-set! stack 2000000)
(stream-ref (solve (lambda (x) x) 1 0.001) 1000)

will produce the correct answer. The downside is that the function calls
will be wrapped recursively which necessitates increasing the stack size.
Plus, it's much slower this way. But it works.
View this message in context:
Sent from the Gnu - Guile - User mailing list archive at

reply via email to

[Prev in Thread] Current Thread [Next in Thread]