clump ( seq n -- array )
Factor documentation > Factor handbook > The language > Collections > Sequence operations > Groups and clumps
Prev:<sliced-groups> ( seq n -- groups )
Next:circular-clump ( seq n -- array )


Vocabulary
grouping

Inputs and outputs
seqa sequence
na non-negative integer
arraya sequence of sequences


Word description
Splits the sequence into overlapping clumps of n elements and collects the clumps into a new array.

Errors
Throws an error if n is larger than the length of the sequence.

Examples
USING: grouping prettyprint ; { 3 1 3 3 7 } 2 clump .
{ { 3 1 } { 1 3 } { 3 3 } { 3 7 } }


See also
circular-clump, group

Definition
USING: sequences ;

IN: grouping

: clump ( seq n -- array ) <clumps> { } like ;