logoalt Hacker News

dreamcompilertoday at 1:00 AM1 replyview on HN

Common Lisp's filter is remove-if which works this way.

(It also has remove-if-not but that's deprecated and if you use it your code smells.)


Replies

shawn_wtoday at 10:08 AM

`remove-if-not` was deprecated before the Common Lisp standard was approved and yet it remained (and will never be removed because the standard will never be updated). That's not deprecated for any practical purpose. And it's more convenient than using `(remove-if (complement #'some-predicate) sequence)`

Scheme has `filter` and `filter-not` in the SRFI-1 list library. Both of which can easily be written using a fold to bring this vaguely on topic.