bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#44205: [PATCH] Add new function seq-remove-item


From: Daniel Martín
Subject: bug#44205: [PATCH] Add new function seq-remove-item
Date: Sun, 25 Oct 2020 17:25:02 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (darwin)

Stefan Kangas <stefan@marxist.se> writes:

> I found myself reaching for a version of `seq-remove' where I don't have
> to supply a lambda but can just give an item.  Ergo, the attached.
>
>     (seq-remove-item 2 '(1 2 3))  => (1 3)
>
> I find it a whole lot nicer than:
>
>     (seq-remove (lambda (a) (= a 2)) '(1 2 3))  => (1 3)
>
> Turns out it could already be used to simplify some code in tab-line.el,
> even if seq is arguably not yet very widely used in our sources.
>
> I did not yet add it to NEWS or the manual; I will do that if people
> agree that this is a good addition.
>
> Comments?

I don't see a clear need for this new function, because there's already

(delete 2 '(1 2 3)) -> Destructs the original list, compares with equal.
(remove 2 '(1 2 3)) -> Keeps the original list, compares with equal.
(delq 2 '(1 2 3)) -> Destructs the argument list, compares with eq.
(remq 2 '(1 2 3)) -> Keeps the original list, compares with eq.

Maybe we could add or improve cross-references in the documentation so
that these functions are more discoverable?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]