unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#59328: 29.0.50; `seq-keep' implementation only valid for lists
@ 2022-11-17  2:17 Michael Heerdegen
  2022-11-19 13:12 ` Eli Zaretskii
  0 siblings, 1 reply; 13+ messages in thread
From: Michael Heerdegen @ 2022-11-17  2:17 UTC (permalink / raw)
  To: 59328; +Cc: Lars Ingebrigtsen, Jonas Bernoulli


Hello,

  [FWIW I tried to reopen 58278 but it seemed to...complicated for me]

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


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...)?


TIA,

Michael.







^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-11-25 11:55 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-17  2:17 bug#59328: 29.0.50; `seq-keep' implementation only valid for lists Michael Heerdegen
2022-11-19 13:12 ` Eli Zaretskii
2022-11-24 13:04   ` Michael Heerdegen
2022-11-24 14:19     ` Eli Zaretskii
2022-11-24 14:26       ` Michael Heerdegen
2022-11-24 15:00         ` Eli Zaretskii
2022-11-24 15:09           ` Michael Heerdegen
2022-11-24 15:15             ` Eli Zaretskii
2022-11-24 15:25               ` Michael Heerdegen
2022-11-24 17:02                 ` Eli Zaretskii
2022-11-25  9:47                   ` Michael Heerdegen
2022-11-25 11:34                     ` Stefan Kangas
2022-11-25 11:55                     ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).