

                                                                     chunk

    FUNCTION
CHUNK M N ITEMS                                                  [Function]

    Package
    series

    DESCRIPTION

This function has the effect of breaking up the input series ITEMS into
(possibly overlapping) chunks of length M.  The starting positions of
successive chunks differ by N.  The inputs M and N must both be positive
integers.

CHUNK produces M output series.  The ith chunk consists of the ith elements
of the M outputs.  Suppose that the length of ITEMS is L.  The length of
each output is the floor of 1+(L-M)/N.  The ith element of the kth output
is the (i*n+k)th element of ITEMS (i and k counting from zero).

The first example below shows CHUNK being used to compute a moving average.
The second example shows CHUNK being used to convert a property list into
an association list.

(MAPPING (((XI XI+1 XI+2) (CHUNK 3 1 #Z(1 5 3 4 5 6))))  
  (/ (+ XI XI+1 XI+2) 3)) => #Z(3 4 4 5)
(COLLECT 
  (MAPPING (((PROP VAL) (CHUNK 2 2 (SCAN '(A 2 B 5 C 8))))) 
    (CONS PROP VAL))) => ((A . 2) (B . 5) (C . 8))


     SEE ALSO
     about-series
     about-generators

;Copyright 1989 by the Massachusetts Institute of Technology,
;Cambridge, Massachusetts.

;Permission to use, copy, modify, and distribute this software and its
;documentation for any purpose and without fee is hereby granted,
;provided that this copyright and permission notice appear in all
;copies and supporting documentation, and that the name of M.I.T. not
;be used in advertising or publicity pertaining to distribution of the
;software without specific, written prior permission. M.I.T. makes no
;representations about the suitability of this software for any
;purpose.  It is provided "as is" without express or implied warranty.

;    M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
;    ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
;    M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
;    ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
;    WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
;    ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
;    SOFTWARE.



