Creation
| Call | Result |
|---|---|
array.new<T>() |
empty |
array.new<T>(size) |
size elements, all na |
array.new<T>(size, default) |
size elements, all default |
array.from(a, b, c, …) |
typed-inferred from the first argument |
array.copy(src) |
shallow copy |
Element access
first = seeded.get(0) // 1.0
seeded.set(0, 42.0) // mutate
.get(i)/.set(i, v)take a 0-based index.- Out-of-range reads return
na(never throw); writes raise a runtime error.
Length
n = seeded.size()
isEmpty = n == 0
Mutating operations
| Call | Meaning |
|---|---|
.push(v) |
append |
.pop() |
remove and return the last element |
.unshift(v) |
prepend |
.shift() |
remove and return the first element |
.insert(i, v) |
insert at index i |
.remove(i) |
delete at index i |
.clear() |
drop all elements |
.reverse() |
in-place reverse |
.sort(order?) |
in-place sort; order is order.ascending (default) or order.descending |
.sort_indices(order?) |
return an array of indices in sorted order |
.fill(v, from?, to?) |
overwrite elements in a range |
Non-mutating accessors
Numeric helpers over array<int> / array<float>:
.sum() .avg() .median() .stdev() .variance() .mode()
.max() .min() .range()
.first() .last() .slice(from, to)
.covariance(other)
.includes(v) .indexof(v) .lastindexof(v)
.binary_search(v) .binary_search_leftmost(v) .binary_search_rightmost(v)
String helper:
.join(separator)
Walking an array
for v in prices
sum := sum + v
for [i, v] in prices
log.info(str.tostring(i) + " → " + str.tostring(v))
See Loops.
Size caps
An array may hold up to 100,000 elements. Attempting to grow beyond that raises a runtime error (array size exceeds 100000). Working-set collections (per-bar scratch space) are rolled back on tick snapshot restoration, same as varip-less var.