;;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- ;;; ;;; SPLIT-SEQUENCE ;;; ;;; This code was based on Arthur Lemmens' in ;;; ; ;;; ;;; 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))