[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#58278: Add new function seq-keep
From: |
Lars Ingebrigtsen |
Subject: |
bug#58278: Add new function seq-keep |
Date: |
Tue, 04 Oct 2022 01:47:59 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
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".)
- bug#58278: Add new function seq-keep, Jonas Bernoulli, 2022/10/03
- bug#58278: Add new function seq-keep,
Lars Ingebrigtsen <=
- bug#58278: Add new function seq-keep, Robert Pluim, 2022/10/04
- bug#58278: Add new function seq-keep, Lars Ingebrigtsen, 2022/10/04
- bug#58278: Add new function seq-keep, Robert Pluim, 2022/10/04
- bug#58278: Add new function seq-keep, Lars Ingebrigtsen, 2022/10/04
- bug#58278: Add new function seq-keep, Robert Pluim, 2022/10/04
- bug#58278: Add new function seq-keep, Lars Ingebrigtsen, 2022/10/04
- bug#58278: Add new function seq-keep, Robert Pluim, 2022/10/04
- bug#58278: Add new function seq-keep, Lars Ingebrigtsen, 2022/10/04
- bug#58278: Add new function seq-keep, Robert Pluim, 2022/10/04
bug#58278: Add new function seq-keep, Jonas Bernoulli, 2022/10/04