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 #41 received at 58278 <at> debbugs.gnu.org (full text, mbox):
Jonas Bernoulli <jonas <at> bernoul.li> writes:
> Yes, that would be an improvement. Some (but certainly not all)
> uses of dash's `-keep' look something like
>
> (-keep (lambda (elt)
> (and (symbolp elt)
> (symbol-name elt)))
> sequence)
>
> and
>
> (seq-keep #'symbol-name sequence #'symbolp)
>
> would be much nicer in those situations.
Hm... That's not exactly what I was thinking here. I was thinking
(cl-defgeneric seq-keep (func sequence &optional pred)
(if pred
(seq-filter pred (seq-mapcar func sequence))
(delq nil (seq-mapcar func sequence))))
which is the traditional "keep" semantics, but allows extending the
concept of "keep" to more than "is non-nil".
But that may well be an overcomplication -- in the unusual cases where
it's not nil that people want to keep, they can just type
(seq-filter pred (seq-mapcar func sequence))
themselves, which has very clear semantics.
So I think, on second consideration, I'd rather just go with
(cl-defgeneric seq-keep (func sequence)
(delq nil (seq-mapcar func sequence)))
like you originally suggested (but with just an argument name change).
This bug report was last modified 2 years and 270 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.