(let ((descriptor (subseq (read-until stream #'terminalp) 1))
(subdescriptors nil))
(do* ((start 0 (1+ end))
- (end (position #\: (subseq descriptor start))
- (position #\: (subseq descriptor start))))
+ (end (position #\: descriptor :start start)
+ (position #\: descriptor :start start)))
((null end)
(push (subseq descriptor start) subdescriptors)
`(oget *root* ,@(reverse subdescriptors)))
(when (funcall predicate x)
(return x)))))
-(defun position (elt sequence &key key (test #'eql testp)
- (test-not #'eql test-not-p))
- (do-sequence (x sequence index)
- (when (satisfies-test-p elt x :key key :test test :testp testp
- :test-not test-not :test-not-p test-not-p )
- (return index))))
+(defun position (elt sequence
+ &key key (test #'eql testp)
+ (test-not #'eql test-not-p)
+ (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)
+ (satisfies-test-p elt x
+ :key key :test test :testp testp
+ :test-not test-not :test-not-p test-not-p))
+ (return index)))))
(defun remove (x seq &key key (test #'eql testp) (test-not #'eql test-not-p))
(cond
(let* ((head (cons nil nil))
(tail head))
(do-sequence (elt seq)
- (unless (satisfies-test-p x elt :key key :test test :testp testp
+ (unless (satisfies-test-p x elt :key key :test test :testp testp
:test-not test-not :test-not-p test-not-p)
(let ((new (list elt)))
(rplacd tail new)
(t
(let (vector)
(do-sequence (elt seq index)
- (if (satisfies-test-p x elt :key key :test test :testp testp
+ (if (satisfies-test-p x elt :key key :test test :testp testp
:test-not test-not :test-not-p test-not-p)
;; Copy the beginning of the vector only when we find an element
;; that does not match.
(if b
(let ((diff (- b a)))
(cond
- ((zerop diff) ())
+ ((zerop diff) ())
((minusp diff)
(error "Start index must be smaller than end index"))
(t
(setq pointer (cdr pointer))
(when (null pointer)
(error "Ending index larger than length of list")))
- (rplacd pointer ())
+ (rplacd pointer ())
drop-a))))
(copy-list (nthcdr a seq))))
((vectorp seq)
((= j b) new)
(aset new i (aref seq j)))))
(t (not-seq-error seq))))
-
-
-