chickadee » srfi-40 » stream-map

stream-map function stream ...procedure

stream-map creates a newly allocated stream built by applying function elementwise to the elements of the streams. The function must take as many arguments as there are streams and return a single value (not multiple values).

The stream returned by stream-map is finite if the given stream is finite, and infinite if the given stream is infinite.

If more than one stream is given, stream-map terminates when any of them terminate, or is infinite if all the streams are infinite. The stream elements are evaluated in order.

(stream-map (lambda (x) (+ x x)) from0)      => (stream 0 2 4 6 8 10 ...)
(stream-map + (stream 1 2 3) (stream 4 5 6)) => (stream 5 7 9)
(stream-map (lambda (x) (expt x x))
  (stream 1 2 3 4 5))                        => (stream 1 4 27 256 3125)