Std.Array
Types
Array
opaque type Array aA persistent, immutable indexed collection backed by Erlang's array module.
Provides O(log n) random access by index — much faster than linked lists
for index-heavy workloads, but slower than lists for sequential processing.
Functions
new
fun new : Unit -> Array aCreates a new empty array.
from_list
fun from_list : (xs: List a) -> Array aCreates an array from a list.
size
fun size : (arr: Array a) -> IntReturns the number of elements in the array.
get
fun get : (index: Int) -> (arr: Array a) -> Maybe aGets the element at the given index. Returns Nothing if out of bounds.
set
fun set : (index: Int) -> (value: a) -> (arr: Array a) -> Array aSets the element at the given index, returning a new array. If the index is beyond the current size, the array is extended with a default value.
to_list
fun to_list : (arr: Array a) -> List aConverts an array to a list.
map
fun map : (f: a -> b) -> (arr: Array a) -> Array bApplies a function to every element, returning a new array.
foldl
fun foldl : (f: b -> a -> b) -> (acc: b) -> (arr: Array a) -> bLeft fold over the array elements, in index order.