Previous: Queues, Up: Compound Data Types
To use procedures for creating and working with streams of objects, evaluate the form:
(use-modules (ice-9 streams))
Historical Note: The basic stream operations are inspired by (i.e. ripped off) Scheme48's `stream' package, modulo stream-empty? -> stream-null? renaming. For procedures that convert streams to lists or vectors, if the stream has infinite length the procedure will not terminate.
Return a stream object controlled by producer and initial-state. producer is a procedure of one argument, the current state. It should return either a pair or an atom (i.e. anything that is not a pair). If producer returns a pair, then the car of the pair is the stream's head value, and the cdr is the state to be fed to producer later. If producer returns a non-pair, then the stream is considered depleted.
Return the first element in stream. This is analogous to
(car list).
Return the first tail of stream. This is analogous to
(cdr list).
Return #t if stream is the end-of-stream marker; otherwise return #f. This is analogous to
(null? list), but should be used whenever testing for the end of a stream.
Return a new stream whose elements are the elements of vector.
Return a new stream whose elements are obtained by reading from port.
Return a new list whose elements are the elements of stream.
Return a new list whose elements are the elements of stream, in reversed order.
Return two values: a new list whose elements are the elements of stream, and the length of the list.
Return two values: a new list whose elements are the elements of stream in reversed order, and the length of the list.
Return a vector whose elements are the elements of stream.
Apply proc to successive elements of the given streams and to the value of the previous invocation (init on the first invocation). Return the last result from proc.
proc must take one more than the number of streams, like this:
(proc car0 ... init)NOTE: The init argument is last, not first. (This was chosen to be consistent the fold procedures from SRFI-1.)