Factor handbook > The language > Collections

Prev:Making sequences with variables

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:

array? ( object -- ? )

Creating new arrays:
>array ( seq -- array )

<array> ( n elt -- array )

Creating an array from several elements on the stack:
1array ( x -- array )

2array ( x y -- array )

3array ( x y z -- array )

4array ( w x y z -- array )

Resizing arrays:
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