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

list

🌌list

list -- feature used to define lists

list provides an abstract type for a sequence of elements of the same type.

A list sequence may be empty and contain no element, or it may have a fixed
or even infitie number of elements.

The core of the implementation of an actual list lies in the implementation
of the actual Cons cell a non-empty list consists of.

Lists can typically be traversed using only immutable data. This makes them
more flexible than streams that require to store and update their state.


create stream from this list

In contrast to list's immutable Cons cells, a stream instance is mutable, i.e,
it cannot be shared with threads or used in pure functions

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 representation of this list including all the string
representations of its contents, separated by ',' and enclosed in '['
and ']'.

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'.

Lazy list concatenation, O(1)

List concatenation, O(count)

count the elements of this list

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

count the elements of this list starting at n.
carries n around to make this tail-recursive

create a list that repeats the current list indefinitely. In case 'list.this'
is 'nil', returns 'nil'

redefines Sequence.cycle:
create a list that repeats the current Sequence indefinitely. In case 'Sequence.this'
is empty, returns 'nil'

create a list from the tail of list.this dropping n elements (or fewer
if the list is shorter than n).

redefines Sequence.drop:
create a list that consists of the elements of this Sequence except the first
n elements

Lazily drop the first elements of a list for which predicate 'p' holds.

redefines Sequence.dropWhile:
Lazily drop the first elements of a list for which predicate 'p' holds.

get the head of this list, panic if list is empty

redefines Sequence.first:
get the head of this list, panic if list is empty

fold the elements of this list using the given monoid and initial value

Used to fold a list tail-recursively

fold the elements of this list using the given monoid.

e.g., to sum the elements of a list of i32, use l.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

call f in order on all elements of this list

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

get the head of this list, panic if list is empty

get the tail of this list, panic if list is empty

get the head of this list if it exists

infix operand synonyme for concat

redefines Sequence.infix ++:
infix operand synonyme for concatSequences

is this list empty?

redefines Sequence.isEmpty:
is this list empty?

get the last element of this list, panic if list is empty

This may take time in O(count), in particular, it may not terminate
for an infinite list.

redefines Sequence.last:
get the last element of this list, panic if list is empty

This may take time in O(count), in particular, it may not terminate
for an infinite list.

map the list to a new list applying function f to all elements

This performs a lazy mapping, f is called only when the elements
are taken from the list.

reverse the order of the elements in this list

recursively reverse the order of the elements in this list
and append the already reversed reversedHead

create a slice from this list that consists of the elements starting at index
'from' (including) up to index 'to' (excluding).

redefines Sequence.slice:
create a slice from this Sequence that consists of the elements starting at index
from (including) up to index to (excluding).

get the tail of this list if it exists, nil if it does
not exist or it is the empty list

create a lazy list of all the tails of this list, including the complete list
'list.this' and the empty list 'nil'.

redefines Sequence.tails:
create a lazy list of all the tails of this list, including the complete list
'list.this' and the empty list 'nil'.

Lazily take the first n elements of a list, alternatively the whole list if it
is shorter than n, or the empty list if n <= 0

redefines Sequence.take:
create a list that consists only of the first n elements of this
Sequence, fewer if this stream has fewer elements

Lazily take the first elements of a list for which predicate 'p' holds.

redefines Sequence.takeWhile:
Lazily take the first elements of a list for which predicate 'p' holds.

create a new list from the result of applying 'f' to the
elements of this list and 'b' in order.