- ((null list)
- nil)
- ((funcall func (car list))
- (cons (car list) (remove-if-not func (cdr list))))
- (t
- (remove-if-not func (cdr list)))))
+ ((listp seq) (list-remove-if func seq t))
+ ((arrayp seq) (vector-remove-if func seq t))
+ (t (not-seq-error seq))))
+
+(defun list-remove-if (func list negate)
+ (if (endp list)
+ ()
+ (let ((test (funcall func (car list))))
+ (if (if negate (not test) test)
+ (list-remove-if func (cdr list) negate)
+ (cons (car list) (list-remove-if func (cdr list) negate))))))
+
+(defun vector-remove-if (func vector negate)
+ (let ((out-vector (make-array 0)))
+ (do-sequence (element vector i)
+ (let ((test (funcall func element)))
+ (when (if negate test (not test))
+ (vector-push-extend element out-vector))))
+ out-vector))