unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Jonas Bernoulli <jonas@bernoul.li>
Cc: 58278@debbugs.gnu.org
Subject: bug#58278: Add new function seq-keep
Date: Tue, 04 Oct 2022 01:47:59 +0200	[thread overview]
Message-ID: <87pmf84ggg.fsf@gnus.org> (raw)
In-Reply-To: <87y1twtx22.fsf@bernoul.li> (Jonas Bernoulli's message of "Mon, 03 Oct 2022 23:30:13 +0200")

Jonas Bernoulli <jonas@bernoul.li> writes:

> Unfortunately I cannot find a replacement for `-keep', which I have been
> using a lot.  I propose that we add something like:
>
>   (cl-defgeneric seq-keep (pred sequence)
>     "Return a list of all non-nil results of (PRED element) for elements in SEQUENCE."
>     (delq nil (seq-map (lambda (elt) (funcall pred elt))
>                        sequence)))

Hm...  well, here PRED isn't a predicate, really, but a transforming
function?  But you wish to filter out the nil results of that
transforming function.

That sounds useful -- there's more than a 100 matches for "delq
nil.*map" in-tree only -- but it's slightly confusing that the function
isn't altogether a predicate, but only kinda.  Would a function
signature like

(cl-defgeneric seq-keep (function sequence &optional pred)
  ...)

make more sense for this combination of map/filter?  (The default
predicate would, of course, be "not null".)





  reply	other threads:[~2022-10-03 23:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-03 21:30 bug#58278: Add new function seq-keep Jonas Bernoulli
2022-10-03 23:47 ` Lars Ingebrigtsen [this message]
2022-10-04 10:05   ` Robert Pluim
2022-10-04 10:13     ` Lars Ingebrigtsen
2022-10-04 10:27       ` Robert Pluim
2022-10-04 10:42         ` Lars Ingebrigtsen
2022-10-04 10:50           ` Robert Pluim
2022-10-04 11:10             ` Lars Ingebrigtsen
2022-10-04 11:21               ` Robert Pluim
2022-10-04 11:23                 ` Lars Ingebrigtsen
2022-10-04 11:37                   ` Robert Pluim
2022-10-04 12:50   ` Jonas Bernoulli
2022-10-04 13:47     ` Lars Ingebrigtsen
2022-10-04 13:56       ` Lars Ingebrigtsen
2022-10-04 13:59         ` Lars Ingebrigtsen
2022-10-04 19:46           ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pmf84ggg.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=58278@debbugs.gnu.org \
    --cc=jonas@bernoul.li \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).