Vectors
Factor handbook » The language » Collections

Prev:Specialized arrays
Next:Byte vectors


The vectors vocabulary implements resizable mutable sequence which support the Sequence protocol.

The vectors vocabulary only includes words for creating new vectors. To access and modify vector elements, use Sequence operations in the sequences vocabulary.

Vector literal syntax is documented in Vector syntax.

Vectors are intended to be used with Destructive sequence operations. Code that does not modify sequences in-place can use fixed-size arrays without loss of generality; see Arrays.

Vectors form a class of objects:
vector

vector? ( object -- ? )


Creating new vectors:
>vector ( seq -- vector )

<vector> ( n -- vector )


Creating a vector from a single element:
1vector ( x -- vector )


If you don't care about initial capacity, an elegant way to create a new vector is to write:
V{ } clone