GNU bug report logs -
#58278
Add new function seq-keep
Previous Next
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
Message #11 received at 58278 <at> debbugs.gnu.org (full text, mbox):
>>>>> On Tue, 04 Oct 2022 01:47:59 +0200, Lars Ingebrigtsen <larsi <at> gnus.org> said:
Lars> 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)))
Lars> Hm... well, here PRED isn't a predicate, really, but a transforming
Lars> function? But you wish to filter out the nil results of that
Lars> transforming function.
Lars> That sounds useful -- there's more than a 100 matches for "delq
Lars> nil.*map" in-tree only -- but it's slightly confusing that the function
Lars> isn't altogether a predicate, but only kinda. Would a function
Lars> signature like
Lars> (cl-defgeneric seq-keep (function sequence &optional pred)
Lars> ...)
Lars> make more sense for this combination of map/filter? (The default
Lars> predicate would, of course, be "not null".)
How is this different from 'cl-mapcan'? (apart from the syntactic sugar)
Robert
--
This bug report was last modified 2 years and 217 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.