set-length ( n seq -- )
Factor handbook » The language » Collections » Sequence operations » Sequence protocol

Prev:?set-nth ( elt n seq -- )
Next:lengthen ( n seq -- )


Vocabulary
sequences

Inputs
na non-negative integer
seqa resizable sequence


Outputs
None

Generic word contract
Resizes a sequence. The initial contents of the new area is undefined.

Errors
Throws a no-method error if the sequence is not resizable, and a bounds-error if the new length is negative.

Side effects
Modifies seq

Examples
USING: kernel prettyprint sequences ; 6 V{ 1 2 3 } [ set-length ] keep .
V{ 1 2 3 0 0 0 }

USING: kernel prettyprint sequences ; 3 V{ 1 2 3 4 5 6 } [ set-length ] keep .
V{ 1 2 3 }


Definition


Methods