3

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.

1
  • 1
    Please edit your post to explain what you want filter to do.
    – Dan
    Commented Oct 28, 2016 at 13:35

2 Answers 2

6

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.

3

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.

1
  • I just wanted to give almost the same answer. You beat me;-).
    – Tobias
    Commented Oct 28, 2016 at 15:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.