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

array

🌌array

array -- one-dimensional immutable array

This is the result type of array<T>(i32, i32 -> T) which creates an
initalized immutable array

create a cons cell for a list of this array starting at the given
index and up to to

create a cons cell for a list of this array starting at the given
index

collect the contents of this Sequence into an array

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

create a list from this array

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 list from this array starting at the given index


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.

get a list of tuples indices and elements in this array

create a cons cell for a list of tuples of this array's indices and elements
starting at the given indices.

§fold(i i32, s T, m Monoid<array.T>)
 => 
T
:
Object

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

Used to fold an array tail-recursively

fold the elements of this array using the given monoid.

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


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

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

create a new array with element i set to v. Grow the array in case i == length.

Complexity: O(array.this.length)

§put(i i32, v T, z T)
 => 
array<array.T>
:
Object

create a new array with element i set to v. Grow the array in case i >= length.
New array elements at indices array.this.length..i-1 will be set to z.

Complexity: O(max(i, array.this.length))

reverse the order of the elements in this array

create a slice from this array's elements at index 'from' (included)
up to 'to' (excluded).

NYI: array.slice should better return an array containing a slice of
internalArray.

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