[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#59328: 29.0.50; `seq-keep' implementation only valid for lists
From: |
Eli Zaretskii |
Subject: |
bug#59328: 29.0.50; `seq-keep' implementation only valid for lists |
Date: |
Sat, 19 Nov 2022 15:12:10 +0200 |
> Cc: Lars Ingebrigtsen <larsi@gnus.org>, Jonas Bernoulli <jonas@bernoul.li>
> From: Michael Heerdegen <michael_heerdegen@web.de>
> Date: Thu, 17 Nov 2022 03:17:46 +0100
>
> The current implementation of the (non-generic!) function `seq-keep':
>
> #+begin_src emacs-lisp
> (defun seq-keep (function sequence)
> (delq nil (seq-map function sequence)))
> ;; ^^^^
> #+end_src
>
> obviously only works when `seq-map' returns a list. This is the case
> for the default implementation of the generic function `seq-map' but not
> necessarily for other implementations of `seq-map'.
>
> We need to filter out the `nil' elements with a way appropriate for any
> sequence type supported by "seq.el" (i.e. with a generic function
> defined in this lib), e.g.
>
> #+begin_src emacs-lisp
> (defun seq-keep (function sequence)
> (seq-filter #'identity (seq-map function sequence)))
> #+end_src
This makes sense to me, so please go ahead and install, preferably
with a test for non-list cases.
> BTW, is the name a good one? Why "keep"? It returns a sequence of
> potentially all completely different elements. And is the function that
> useful and a good abstraction at all (I don't have thought about it
> too long...)?
FWIW, "keep" doesn't sound problematic to me.
Thanks.
- bug#59328: 29.0.50; `seq-keep' implementation only valid for lists, Michael Heerdegen, 2022/11/16
- bug#59328: 29.0.50; `seq-keep' implementation only valid for lists,
Eli Zaretskii <=
- bug#59328: 29.0.50; `seq-keep' implementation only valid for lists, Michael Heerdegen, 2022/11/24
- bug#59328: 29.0.50; `seq-keep' implementation only valid for lists, Eli Zaretskii, 2022/11/24
- bug#59328: 29.0.50; `seq-keep' implementation only valid for lists, Michael Heerdegen, 2022/11/24
- bug#59328: 29.0.50; `seq-keep' implementation only valid for lists, Eli Zaretskii, 2022/11/24
- bug#59328: 29.0.50; `seq-keep' implementation only valid for lists, Michael Heerdegen, 2022/11/24
- bug#59328: 29.0.50; `seq-keep' implementation only valid for lists, Eli Zaretskii, 2022/11/24
- bug#59328: 29.0.50; `seq-keep' implementation only valid for lists, Michael Heerdegen, 2022/11/24
- bug#59328: 29.0.50; `seq-keep' implementation only valid for lists, Eli Zaretskii, 2022/11/24
- bug#59328: 29.0.50; `seq-keep' implementation only valid for lists, Michael Heerdegen, 2022/11/25
- bug#59328: 29.0.50; `seq-keep' implementation only valid for lists, Stefan Kangas, 2022/11/25