<slice> ( from to seq -- slice )
Factor handbook > The language > Collections > Sequence operations > Subsequences and slices

Prev:slice? ( object -- ? )
Next:head-slice ( seq n -- slice )


Inputs and outputs
froma non-negative integer
toa non-negative integer
seqa sequence
slicea slice

Word description
Outputs a new virtual sequence sharing storage with the subrange of elements in seq with indices starting from and including from, and up to but not including to.

Throws an error if from or to are out of bounds.

Taking the slice of a slice outputs a slice of the underlying sequence, instead of a slice of a slice. This means that you cannot assume that the from and to slots of the resulting slice will be equal to the values you passed to <slice>.

See also