

                                                                      split
                                                                   split-if

    FUNCTION
SPLIT ITEMS &rest TEST-SERIES-INPUTS                             [Function]
SPLIT-IF ITEMS &rest TEST-PREDICATES                             [Function]

    Package
    series

    DESCRIPTION

These functions are like CHOOSE and CHOOSE-IF except that instead of
producing one restricted output, they partition the input series ITEMS
between several outputs.  If there are N test inputs following ITEMS, then
there are N+1 outputs.  Each input element is placed in exactly one output
series, depending on the outcome of a sequence of tests.  If the element
ITEMS[j] fails the first K-1 tests and passes the kth test, it is put in
the kth output.  If ITEMS[j] fails every test, it is placed in the last
output.  In addition, all output stops as soon as any series input runs out
of elements.  The test inputs to SPLIT are series of values; ITEMS[j]
passes the kth test if the jth element of the kth test-series is not NIL.
The test inputs to SPLIT-IF are predicates; ITEMS[j] passes the kth test if
the kth test predicate returns non-null when applied to ITEMS[j].

(SPLIT #Z(-1 2 3 -4) #Z(T NIL NIL T)) => #Z(-1 -4) and #Z(2 3) 
(MULTIPLE-VALUE-BIND (+X -X) (SPLIT-IF  #Z(-1 2 3 -4) #'PLUSP) 
  (VALUES (COLLECT-SUM +X) (COLLECT-SUM -X))) 
 => 5 and -5


     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.



