38 lines
1.3 KiB
Common Lisp
38 lines
1.3 KiB
Common Lisp
|
|
;;;; -*- Mode: Lisp; indent-tabs-mode: nil -*-
|
||
|
|
;;;
|
||
|
|
;;; SPLIT-SEQUENCE
|
||
|
|
;;;
|
||
|
|
;;; This code was based on Arthur Lemmens' in
|
||
|
|
;;; <URL:http://groups.google.com/groups?as_umsgid=39F36F1A.B8F19D20%40simplex.nl>;
|
||
|
|
;;;
|
||
|
|
;;; changes include:
|
||
|
|
;;;
|
||
|
|
;;; * altering the behaviour of the :from-end keyword argument to
|
||
|
|
;;; return the subsequences in original order, for consistency with
|
||
|
|
;;; CL:REMOVE, CL:SUBSTITUTE et al. (:from-end being non-NIL only
|
||
|
|
;;; affects the answer if :count is less than the number of
|
||
|
|
;;; subsequences, by analogy with the above-referenced functions).
|
||
|
|
;;;
|
||
|
|
;;; * changing the :maximum keyword argument to :count, by analogy
|
||
|
|
;;; with CL:REMOVE, CL:SUBSTITUTE, and so on.
|
||
|
|
;;;
|
||
|
|
;;; * naming the function SPLIT-SEQUENCE rather than PARTITION rather
|
||
|
|
;;; than SPLIT.
|
||
|
|
;;;
|
||
|
|
;;; * adding SPLIT-SEQUENCE-IF and SPLIT-SEQUENCE-IF-NOT.
|
||
|
|
;;;
|
||
|
|
;;; * The second return value is now an index rather than a copy of a
|
||
|
|
;;; portion of the sequence; this index is the `right' one to feed to
|
||
|
|
;;; CL:SUBSEQ for continued processing.
|
||
|
|
|
||
|
|
;;; There's a certain amount of code duplication in the vector and
|
||
|
|
;;; extended sequence modules, which is kept to illustrate the
|
||
|
|
;;; relationship between the SPLIT-SEQUENCE functions and the
|
||
|
|
;;; CL:POSITION functions.
|
||
|
|
|
||
|
|
(defpackage #:split-sequence
|
||
|
|
(:use #:common-lisp)
|
||
|
|
(:export #:split-sequence
|
||
|
|
#:split-sequence-if
|
||
|
|
#:split-sequence-if-not))
|