Next: , Previous: , Up: streams   [Index]

1.15.4 Converting streams to objects

Function: stream->list stream
Function: stream->list stream n

Take a natural number n and a stream and return a newly–allocated list containing in its elements the first n items in the stream. If the stream has less than n items all the items in the stream will be included in the returned list. If n is not given it defaults to infinity, which means that unless stream is finite stream->list will never return.


(stream->list 10
  (stream-map (lambda (x) (* x x))
    (stream-from 0)))
  => (0 1 4 9 16 25 36 49 64 81)