Start with a value for z
and make your function fz(x)
like:
(define (make-fz z) (lambda (x) (+ z (* 2 x))))
Now, using srfi-41 stream library, define a stream just as you've indicated:
Try it out (with z
of 0
):
> (stream->list (stream-take 10 (stream-iterate (make-fz 0) 1)))
(1 2 4 8 16 32 64 128 256 512)
Note: that stream-iterate
is defined something like:
(define-stream (stream-iterate fz a)
(stream-cons a (stream-iterate fz (fz a))))