OSET* and OGET* type-preserving variants and *root* Javascript object
[jscl.git] / src / sequence.lisp
index d7dae46..85d5276 100644 (file)
@@ -55,7 +55,7 @@
                            :test-not test-not :test-not-p test-not-p ) 
       (return index))))
 
-(defun remove (x seq)
+(defun remove (x seq &key key (test #'eql testp) (test-not #'eql test-not-p))
   (cond
     ((null seq)
      nil)
@@ -63,7 +63,8 @@
      (let* ((head (cons nil nil))
             (tail head))
        (do-sequence (elt seq)
-         (unless (eql x elt)
+         (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)
              (setq tail new))))
@@ -71,7 +72,8 @@
     (t
      (let (vector)
        (do-sequence (elt seq index)
-         (if (eql x elt)
+         (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.
              (unless vector
               (rplacd pointer ()) 
               drop-a))))
        (copy-list (nthcdr a seq))))
-    ((arrayp seq) 
-     (if b
-       (slice seq a b)
-       (slice seq a)))
+    ((vectorp seq)
+     (let* ((b (or b (length seq)))
+            (size (- b a))
+            (new (make-array size :element-type (array-element-type seq))))
+       (do ((i 0 (1+ i))
+            (j a (1+ j)))
+           ((= j b) new)
+         (aset new i (aref seq j)))))
     (t (not-seq-error seq))))
+
+
+