3.14.2 Streams
A stream is a kind of sequence that supports functional
iteration via stream-first and stream-rest. The
stream-cons form constructs a lazy stream, but plain lists
can be used as stream, and functions such as in-range and
in-naturals also create streams.
Returns
#t if
v can be used as a
stream,
#f otherwise.
Returns #f if s has no elements, #f
otherwise.
Returns the value(s) of the first element in s.
Returns a stream that is equivalent to s without its
first element.
Produces a lazy stream for which
stream-first forces the
evaluation of
first-expr to produce the first element of the
stream, and
stream-rest forces the evaluation of
rest-expr to produce a stream for the rest of the returned
stream.
The first element of the stream as produced by first-expr
must be a single value. The rest-expr must produce a stream
when it is evaluated, otherwise the exn:fail:contract? exception is raised.
Returns a sequence that is equivalent to s.
An
in-stream application can provide better performance for streams iteration when it appears directly in a
for clause.
A stream with no elements.
Returns a list whose elements are the elements of s,
each of which must be a single value. If s is infinite, this
function does not terminate.
Returns the number of elements of s. If s is
infinite, this function does not terminate.
In the case of lazy streams, this function forces evaluation only of
the sub-streams, and not the stream’s elements.
Returns the ith element of s (which may be
multiple values).
Returns a stream equivalent to s, except that the first
i elements are omitted.
In case extracting elements from s involves a side effect,
they will not be extracted until the first element is extracted from
the resulting stream.
Returns a stream that contains all elements of each stream in the
order they appear in the original streams. The new stream is
constructed lazily.
Returns a stream that contains f applied to each element of
s. The new stream is constructed lazily.
Returns #t if f returns a true result on every
element of s. If s is infinite and f never
returns a false result, this function does not terminate.
Returns #t if f returns a true result on some
element of s. If s is infinite and f never
returns a true result, this function does not terminate.
Applies f to each element of s. If s is
infinite, this function does not terminate.
Folds f over each element of s with i as
the initial accumulator. If s is infinite, this function
does not terminate.
Returns the number of elements in s for which f
returns a true result. If s is infinite, this function does
not terminate.
Returns a stream whose elements are the elements of s for
which f returns a true result. Although the new stream is
constructed lazily, if s has an infinite number of elements
where f returns a false result in between two elements where
f returns a true result, then operations on this stream will
not terminate during the infinite sub-stream.
Returns a stream whose elements are the elements of s,
but with e between each pair of elements in s.
The new stream is constructed lazily.
Associates three procedures to a structure type to implement stream
operations for instances of the structure type.
The property value must be a vector of three procedures: a
stream-empty? implementation, a stream-first
implementation, and a stream-rest implementation. The
procedures are applied only to instances of the structure type that
has the property value.