☰
array
array
Functions
is this sequence known to be finite? For infinite sequences, features like
count diverge.
count diverge.
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
like index[] are fast.
redefines Sequence.count for array,
reducing complexity from O(n) to O(1).
reducing complexity from O(n) to O(1).
collect the contents of this Sequence into an array
apply f to all elements in this array
reverse the order of the elements in this array
create a list that consists of the elements of this Sequence except the first
n elements
For arrays, this has performance in O(1).
n elements
For arrays, this has performance in O(1).
get the contents of this array at the given index
create a slice from this array's elements at index 'from' (included)
up to 'to' (excluded).
Complexity:
index access : O(1)
count : O(1)
up to 'to' (excluded).
Complexity:
index access : O(1)
count : O(1)
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
e.g., to sum the elements of an array of i32, use a.fold i32.sum
fold the elements of this array using the given monoid and initial value
Used to fold an array tail-recursively
Used to fold an array tail-recursively
a sequence of all valid indices to access this array. Useful e.g., for
`for`-loops:
for i in arr.indices do
`for`-loops:
for i in arr.indices do
create a new array with element i set to v. Grow the array in case i == length.
Complexity: O(array.this.length)
Complexity: O(array.this.length)
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))
New array elements at indices array.this.length..i-1 will be set to z.
Complexity: O(max(i, array.this.length))
map the array to a new array applying function f to all elements
variant of map which additionally passes the index to
the mapping function f
the mapping function f
reverse the order of the elements in this array
get a list of tuples indices and elements in this array
Type Features
array -- create initialized one-dimensional immutable array
This is the result type of array(type, i32, i32 -> T) which creates an
initialized immutable array
Note: This uses dummy unit-type args to avoid
name clash with routine array(T,length,init).