[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Emacs-diffs] master 176a617: Add filter macro, which does what you
Re: [Emacs-diffs] master 176a617: Add filter macro, which does what you expect.
Tue, 02 Dec 2014 17:43:43 -0500
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)
> + * subr.el (filter): New macro. Because it's just silly for a Lisp
> + not to have this in 2014. And VC needs it.
Elisp does have it. It's called cl-remove-if-not.
> +(defmacro filter (condp lst)
> + "Return the list consisting of elements in LST for which CONDP is not nil."
> + `(delq nil
> + (mapcar (lambda (x) (and (funcall ,condp x) x)) ,lst)))
Why define this as a macro, when it's obviously intended to behave as
a function? And of course, this will misbehave if one of the elements
that should be kept is nil.
Also, we have a seq-filter in the new seq.el library that's pending
inclusion, so this poorly cobbled-up `filter' in subr.el is definitely
- Re: [Emacs-diffs] master 176a617: Add filter macro, which does what you expect.,
Stefan Monnier <=