Array: the growable container – amortized O(1) push!, O(1) indexed access, over a vector backing store.
Backing VECTOR doubles on overflow; slot 0 of the backing store is its capacity.
ArrayA growable container: amortized O(1) push!, O(1) ref/set!, backed by a doubling VECTOR.
Mutators (push!/set!) return the array for chaining; pop! returns the removed element.
storeMember: data carried by a Array instance.
lenMember: data carried by a Array instance.
(Array make . opt)An empty array. Pass a capacity to pre-size the backing store.
Parameters:
LIST — Optional (capacity) – initial backing size, default 8Returns: Array — A new empty array
(Array from-list lst)Build an array from a list’s elements.
Parameters:
LIST — Elements, in orderReturns: Array — An array holding the list’s elements
Examples:
((Array from-list (list 1 2 3)) length) => 3(Array of . args)Variadic literal: an array of the arguments.
Parameters:
ANY — Elements, in orderReturns: Array — An array holding the arguments
Examples:
((Array of 1 2 3) ->list) => (1 2 3)(%live)Instance method: called on a Array instance.
(%index i what)Instance method: called on a Array instance.
(push! x)Append an element (doubling the backing store when full); returns the array for chaining.
Instance method: called on a Array instance.
Parameters:
ANY — Element to appendReturns: Array — self
(pop!)Remove and return the last element; errors when empty.
Instance method: called on a Array instance.
Returns: ANY — The removed element
(ref i)The element at index i (negative counts from the end); errors out of range.
Instance method: called on a Array instance.
Parameters:
INT — Zero-based indexReturns: ANY — Element at i
(set! i x)Store x at index i (in place; negative counts from the end); errors out of range; returns the array for chaining.
Instance method: called on a Array instance.
Parameters:
INT — Zero-based indexANY — Value to storeReturns: Array — self
(length)The live element count.
Instance method: called on a Array instance.
Returns: INT — Element count
(empty?)Test whether the array holds no elements.
Instance method: called on a Array instance.
Returns: BOOL — #t when empty
(->list)The elements as a list, in order.
Instance method: called on a Array instance.
Returns: LIST — List of elements