anchor.diff:  (in-package :iolib.base)
   
   (defun split-sequence (delimiter seq &key (start 0) (end nil) (from-end nil)
  -                       (count nil) (remove-empty-subseqs nil) (test nil test-supplied)
  -                       (test-not nil test-not-supplied) (key nil key-supplied))
  +                       (count nil) (remove-empty-subseqs nil)
  +                       (test #'eql) (test-not nil) (key #'identity))
     "Return a list of subsequences in seq delimited by delimiter.
   
   If :remove-empty-subseqs is NIL, empty subsequences will be included
  
positive.code: :count is supplied. The second return value is an index suitable as an
  argument to CL:SUBSEQ into the sequence indicating where processing
  stopped."
    (let ((len (length seq))
          (other-keys (nconc (when test-supplied
                               (list :test test))
                             (when test-not-supplied
                               (list :test-not test-not))
                             (when key-supplied
                               (list :key key)))))
      (unless end (setf end len))
      (if from-end
          (split-from-end #'position delimiter seq other-keys
                          start end count remove-empty-subseqs)
          (split-from-start #'position delimiter seq len other-keys
                            start end count remove-empty-subseqs))))
  
  (defun split-sequence-if (predicate seq &key (start 0) (end nil) (from-end nil)
                            (count nil) (remove-empty-subseqs nil) (key nil key-supplied))
    "Return a list of subsequences in seq delimited by items satisfying
  predicate.
  
  
negative.code: :count is supplied. The second return value is an index suitable as an
  argument to CL:SUBSEQ into the sequence indicating where processing
  stopped."
    (let ((len (length seq)))
      (unless end (setf end len))
      (if from-end
          (split-from-end (lambda (end)
                            (position-if-not predicate seq :end end :from-end t :key key))
                          seq start end count remove-empty-subseqs)
          (split-from-start (lambda (start)
                              (position-if-not predicate seq :start start :key key))
                            seq len start end count remove-empty-subseqs))))
  
  (defun split-from-end (position-fn seq start end count remove-empty-subseqs)
    (loop
       :for right := end :then left
       :for left := (max (or (funcall position-fn right) -1)
                         (1- start))
       :unless (and (= right (1+ left))
                    remove-empty-subseqs) ; empty subseq we don't want
       :if (and count (>= nr-elts count))
       ;; We can't take any more. Return now.
         :return (values (nreverse subseqs) right)
       :else
         :collect (subseq seq (1+ left) right) into subseqs
         :and :sum 1 :into nr-elts
       :until (< left start)
       :finally (return (values (nreverse subseqs) (1+ left)))))
  
  (defun split-from-start (position-fn seq len start end count remove-empty-subseqs)
    (loop
       :for left := start :then (+ right 1)
       :for right := (min (or (funcall position-fn left) len)
                          end)
       :unless (and (= right left)
                    remove-empty-subseqs) ; empty subseq we don't want
       :if (and count (>= nr-elts count))
       ;; We can't take any more. Return now.
         :return (values subseqs left)
       :else
         :collect (subseq seq left right) :into subseqs
         :and :sum 1 :into nr-elts
       :until (>= right end)
       :finally (return (values subseqs right))))
  