<clumps> ( seq n -- clumps )
Factor handbook > The language > Collections > Sequence operations > Groups and clumps

Prev:clumps
Next:circular-clumps


Vocabulary
grouping

Inputs and outputs
seqa sequence
na non-negative integer
clumpsa clumps


Word description
Outputs a virtual sequence whose elements are overlapping subsequences of n elements from the underlying sequence.

Examples
Running averages:
USING: grouping sequences math prettyprint kernel ; IN: scratchpad CONSTANT: share-price { 13/50 51/100 13/50 1/10 4/5 17/20 33/50 3/25 19/100 3/100 } share-price 4 <clumps> [ [ sum ] [ length ] bi / ] map .
{ 113/400 167/400 201/400 241/400 243/400 91/200 1/4 }

USING: arrays kernel sequences grouping prettyprint ; { 1 2 3 4 5 6 } 3 <clumps> second >array .
{ 2 3 4 }


See also
<circular-clumps>, <groups>

Definition