Array Functions

These are a sample of useful common array functions.

array_copy :: (array: [] $T) -> [] T;

Copies the array and returns the result as an array view.

array_free :: (array: [] $T);

Frees the heap allocated array.

array_add :: (array: *[..]$T, item: T);

Adds an element to the end of a dynamically allocated array.

array_find :: (array: [] $T, item: T) -> bool, s64;

Finds an element in an array.

peek :: inline (array: [] $T) -> T;

Treats the array as a stack. Peeks the last element of an array.

pop :: (array: *[] $T) -> T;

Treats the array as a stack. Pops the last element of an array.

array_reset :: (array: *[..] $T);

Resets all the memory in the array.

array_reserve :: (array: *[..] $T, desired_items: s64);

Reserves a certain amount of elements in an array.

1 Like