- You can use the mapcarfunction to iterate through each item in the list
- In the mapcar function you can perform a predicate that will turn matches into some known value that can be removed
- The deletefunction can remove all instances of some value from a list
- The deletefunction will mutate the list
- The removefunction will do the same but not mutate the list
- There are also seq-filterandseq-removein theseq.ellibrary.
(defun ajr-filter (pred seq)
  "Return a copy of `seq' with all items that match `pred' filtered out."
  (let ((remove-val -99988844421))
    (remove remove-val
            (mapcar
             (lambda (i)
               (if (funcall pred i)
                   remove-val
                 i))
             seq))))
(setq x (list 1 2 'bbb 3 4 5 6 7 9))
(print (ajr-filter (lambda (n) (or (equal n 'bbb)
                                   (equal n 2))) x))
(print x)
(require 'seq)
(print (seq-filter (lambda (n) (not (equal n 'bbb))) x))
(print (seq-remove (lambda (n) (not (equal n 'bbb))) x))
(print x)