Arrays - Factor Documentation (original) (raw)
The arrays vocabulary implements fixed-size mutable sequences which support the Sequence protocol.
The arrays vocabulary only includes words for creating new arrays. To access and modify array elements, use Sequence operations in the sequences vocabulary.
Array literal syntax is documented in Array syntax. Resizable arrays also exist and are known as Vectors.
Arrays form a class of objects:
Creating an array from several elements on the stack:
2array ( x y -- array )
3array ( x y z -- array )
4array ( w x y z -- array )
resize-array ( n array -- new-array )
The class of two-element arrays:
Arrays can be accessed without bounds checks in a pointer unsafe way. Unsafe array operations