Arrays are the mutable indexed type in Janet. They contain a sequence of values that are keyed with an index. They can also be used to implement stacks and queues. See the Arrays documentation for more info.
(array/concat arr & parts) Concatenates a variadic number of arrays (and tuples) into the first argument which must an array. If any of the parts are arrays or tuples, their elements will be inserted into the array. Otherwise, each part in parts will be appended to arr in order. Return the modified array arr.
(array/ensure arr capacity) Ensures that the memory backing the array is large enough for capacity items. Capacity must be an integer. If the backing capacity is already enough, then this function does nothing. Otherwise, the backing memory will be reallocated so that there is enough space.
(array/insert arr at & xs) Insert all of xs into array arr at index at. at should be an integer 0 and the length of the array. A negative value for at will index from the end of the array, such that inserting at -1 appends to the array. Returns the array.
(array/new capacity) Creates a new empty array with a pre-allocated capacity. The same as (array) but can be more efficient if the maximum size of an array is known.
(array/peek arr) Returns the last element of the array. Does not modify the array.
(array/pop arr) Remove the last element of the array and return it. If the array is empty, will return nil. Modifies the input array.
(array/push arr x) Insert an element in the end of an array. Modifies the input array and returns it.
(array/remove arr at &opt n) Remove up to n elements starting at index at in array arr. at can index from the end of the array with a negative index, and n must be a non-negative integer. By default, n is 1. Returns the array.
(array/slice arrtup &opt start end) Takes a slice of array or tuple from start to end. The range is half open, [start, end). Indexes can also be negative, indicating indexing from the end of the end of the array. By default, start is 0 and end is the length of the array. Returns a new array.