Hello, On Fri 14 May 2010 23:53, user8472 <head_over_he...@freenet.de> writes:
> The solution is thus to wrap the defines in (lambda () ...)s. > > <code> > (define (solve f y0 dt) > (define (y) (integral (delay (dy)) y0 dt)) > (define (dy) (stream-map f (y))) > (y)) > > (debug-set! stack 2000000) > (stream-ref (solve (lambda (x) x) 1 0.001) 1000) > </code> > > 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. The fact that it's slow is an implementation detail. Lambda expressions are simply abstractions over scope -- they do not necessitate the creation of closures. Guile 2.0 is already much faster for this case, I believe, and with a proper inliner, y and dy would not actually be implemented with functions. Andy -- http://wingolog.org/