X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fsequence.lisp;h=7f86a85127d71162fe0af2ed7d42b67197ac8f5a;hb=be500b83eef452b448bfb9225e12846908ac8fc9;hp=981f5592b58fd3f5a394220cb65ecc04d662a030;hpb=fd8bc90cbea141dc226097a8bd7fa71ba55ee481;p=jscl.git diff --git a/src/sequence.lisp b/src/sequence.lisp index 981f559..7f86a85 100644 --- a/src/sequence.lisp +++ b/src/sequence.lisp @@ -63,6 +63,22 @@ :test-not test-not :test-not-p test-not-p)) (return index))))) +;; TODO: need to support &key from-end +(defun position-if (predicate sequence + &key key (start 0) end) + ;; TODO: Implement START and END efficiently for all the sequence + ;; functions. + (let ((end (or end (length sequence)))) + (do-sequence (x sequence index) + (when (and (<= start index) + (< index end) + (funcall predicate (if key (funcall key x) x))) + (return index))))) + +(defun position-if-not (predicate sequence + &key key (start 0) end) + (position-if (complement predicate) sequence :key key :start start :end end)) + (defun remove (x seq &key key (test #'eql testp) (test-not #'eql test-not-p)) (cond ((null seq)