Hi,
Here's a recursive way for remove (vl-remove)
(defun remove (item lst)
(if lst
(if (equal item (car lst))
(remove item (cdr lst))
(cons (car lst) (remove item (cdr lst)))
)
)
)
For remove-if, an argument should be a predicate function:
(defun remove-if (fun lst)
(if lst
(if (apply fun (list (car lst)))
(remove-if fun (cdr lst))
(cons (car lst) (remove-if fun (cdr lst)))
)
)
)
To search an item in a list, you'd rather stop the process when the first occurence is found
A recursive way
(defun countains (item lst)
(if lst
(or (equal item (car lst))
(countains1 item (cdr lst))
)
)
)
An iterative way
(defun countains (item lst / found)
(while (and (not found) lst)
(if (equal item (car lst))
(setq found T)
(setq lst (cdr lst))
)
)
found
)