lispmxEn 2021-06-10 14:45:07

Write a function filter which takes a list and a predicate, and returns the list of the elements fromthe original list for which the predicate returns true. (There are actually LISP built-ins  to  do  thiscalled remove-if and remove-if-nott. Of course you may not use them for this problem!)


? (defun even(num) (= (mod num 2) 0))

? (filter '(6 4 3 5 2) #'even)

(6 4 2)


source:

https://cs.stanford.edu/people/nick/compdocs/LISP_Examples.pdf