GNU bug report logs - #58278
Add new function seq-keep

Previous Next

Package: emacs;

Reported by: Jonas Bernoulli <jonas <at> bernoul.li>

Date: Mon, 3 Oct 2022 21:31:02 UTC

Severity: normal

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Jonas Bernoulli <jonas <at> bernoul.li>
Cc: 58278 <at> debbugs.gnu.org
Subject: bug#58278: Add new function seq-keep
Date: Tue, 04 Oct 2022 01:47:59 +0200
Jonas Bernoulli <jonas <at> 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".)




This bug report was last modified 2 years and 271 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.