☰
stream
stream
Constructors
NYI this was broken but is meanwhile fixed.
Should be removed eventually.
Should be removed eventually.
Functions
create a string from the elements of this stream
create a string representation of this stream including all the string
representations of its contents, separated by 'sep'.
representations of its contents, separated by 'sep'.
collect all items from this stream into an array
apply f to all elements in this stream
fold the elements of this stream using the given monoid.
e.g., to sum the elements of a stream of i32, use s.fold i32.sum
e.g., to sum the elements of a stream of i32, use s.fold i32.sum
fold the elements of this stream using the given monoid m and initial value s.
e.g., to sum the elements of a stream of i32, use s.fold i32.sum
e.g., to sum the elements of a stream of i32, use s.fold i32.sum
Return this stream as a stream.
This is a helper function that needs to be defined because stream is an heir
of Sequence.
This is a helper function that needs to be defined because stream is an heir
of Sequence.
apply 'f' to each element 'e' as long as 'f e'
check if predicate f holds for all elements produced by this stream
check if predicate f holds for at least one element produced by this stream
take n items from stream, less if stream has fewer than n items
map the stream to a new stream applying function f to all elements
This performs a lazy mapping, f is called only when the elements
are taken from the stream.
This performs a lazy mapping, f is called only when the elements
are taken from the stream.
A stream contains mutable state, so it cannot be reused or shared
between threads.
The mutable nature of streams requires particular prudence, as even basic
actions, such as calling as_string on a stream will consume values and thus
change the state of the stream, as the following example demonstrates:
a := [1, 2, 3, 4, 5].as_stream
say a
say a
In this example, the first invocation of say will print "1, 2, 3, 4, 5",
the second invocation will print "".
NYI: Check if stream should be replaced by a lazy list, which is a choice
of either nil or a tuple (head, tail). This should avoid the need to store
mutable state.