Fuzion Logo
flang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.

stream

🌌stream

stream -- a stream of values

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.

collect all items from this stream into an array

redefines Sequence.asArray:
collect the contents of this Sequence into an array

create a list from this stream

redefines Sequence.asList:
create a list from this Sequence.

A list is immutable, so it can be reused and shared between threads.
Compared to a stream, a list may require more (heap) allocation.

Default implementation uses asStream. Heirs must redefine at least
one of asList or asStream.

create a stream of T.

A stream contains mutable state, so it cannot be reused or shared
between threads.

Default implementation uses asList. Heirs must redefine at least
one of asList or asStream.

redefines Sequence.asStream:
create a stream of T.

A stream contains mutable state, so it cannot be reused or shared
between threads.

Default implementation uses asList. Heirs must redefine at least
one of asList or asStream.

create a string from the elements of this stream

redefines Sequence.asString:
create a string representation of this list including all the string
representations of its contents, separated by ',' and enclosed in '['
and ']'.

redefines Object.asString:

create a string representation of this list including all the string
representations of its contents, separated by 'sep'.

redefines Sequence.asString:
create a string representation of this list including all the string
representations of its contents, separated by 'sep'.

create a new stream that contains the first elements of this stream for
which 'f e' is false

redefines Sequence.before:
create a new stream that contains the first elements of this stream for
which 'f e' is false

create a stream that consists of all be the elements if this stream followed
by all the elements of s

count the elements of this stream

redefines Sequence.count:
count the number of elements in this Sequence. Note that this typically
runs forever if executed on an endless list

create new stream from all elements for which predicate f is true

redefines Sequence.filter:
create a new stream and filter its elements using predicate f

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

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

redefines Sequence.fold:
fold the elements of this Sequence using the given monoid.

e.g., to sum the elements of a stream of i32, use s.fold i32.sum

apply f to all elements in this stream

redefines Sequence.forAll:
create a stream and call 'forAll f' on it

apply 'f' to each element 'e' as long as 'f e'

redefines Sequence.forWhile:
create a new stream and apply 'f' to each element 'e' as long as 'f e'

does this stream have one more element?

create a new stream from all elements for which predicate f is true, infix
operator synonyme of filter.

NYI: What is better, 'infix |&' or 'infix &', or something else?

redefines Sequence.infix &:
create a new stream and filter its elements using predicate f, infix operator
synonyme of filter.

NYI: What is better, 'infix |&' or 'infix &', or something else?

apply f to all elements in this stream, infix operator synonyme of forAll.

redefines Sequence.infix |:
create a stream and have it consumed by f, infix operator synonyme of forAll.

create a new stream from all elements for which predicate f is true, infix
operator synonyme of filter.

redefines Sequence.infix |&:
create a new stream and filter its elements using predicate f, infix operator
synonyme of filter.

check if predicate f holds for all elements produced by this stream

redefines Sequence.infix ∀:
create a stream and check if predicate f holds for all elements produced

check if predicate f holds for at least one element produced by this stream

redefines Sequence.infix ∃:
create a stream and check if predicate f holds for at least one element produced

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.

NYI: This currently does not work with the C backend since generics resolution
for stream.this.next confuses the type from the outer feature (T) with the type
from the inherited feature (B).

the next element in this stream

get the next element or nil if !hasNext

print the elements of this stream