In 25.1 there is (still) no builtin algorithm named filter
. Why? What should I use instead? I think I've read somewhere that a standardized filter algorithm should be added to Emacs.
2 Answers
My crystal ball tells me that you want
(require 'seq)
and then
... (seq-filter ...) ...
The seq
package is built-in, even though you have to say explicitly when you want to use it. Of course it's still not called filter
, you may say, so you additionally need
(defalias 'filter #'seq-filter)
tho I'd advise against doing that.
Does it need to be "named filter
"?
As @Stefan mentions, seq-filter
is available in Emacs 25.1.
Earlier releases, going back to almost forever, have functions remove-if
and remove-if-not
, in library cl.el
. Recent releases provide the same functions under the names cl-remove-if
and cl-remove-if-not
, in library cl-seq.el
(so you need not load library cl.el
at runtime, to get them).
All of these do essentially the same thing, and probably the same thing as what you are requesting (whose behavior is not really specified). You can of course name any of them "filter
" using defalias
, if you want.
-
I just wanted to give almost the same answer. You beat me;-).– TobiasCommented Oct 28, 2016 at 15:16
filter
to do.