[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: seq-some-p and nil
From: |
Drew Adams |
Subject: |
RE: seq-some-p and nil |
Date: |
Mon, 7 Sep 2015 01:06:51 -0700 (PDT) |
> >> I also liked seq-some-p returning the matching element over cl-some
> >> returning the value returned by the predicate.
> >
> > But if the matched element is nil ...
>
> If the function is not supposed to return non-nil if an element is
> matched but the element itself, then would it be ok? OTOH there would be
> again no way to differentiate between no element found and nil being
> found in the sequence.
1. That's too big a weakness. It means that `seq-some' cannot
be used as a predicate. (Again, lose the suffix `-p' if the
return value is important as something other than a Boolean.)
2. You can return both the sequence element and the value of the
predicate applied to it, as a cons: (ELEMENT . VALUE).
If the element is nil then the return value is (nil . VALUE).
That gives you both kinds of info, at the cost of a cons and
the trouble to dig out what you need from the cons.
3. If you never care about the VALUE, you could just return a
cons with the sequence element. For nil the return value
would then be (nil).
#2 sounds reasonable.
- Re: seq-some-p and nil, (continued)
- Re: seq-some-p and nil, Stefan Monnier, 2015/09/03
- Re: seq-some-p and nil, Artur Malabarba, 2015/09/03
- Re: seq-some-p and nil, Nicolas Petton, 2015/09/03
- Re: seq-some-p and nil, Mark Oteiza, 2015/09/05
- Re: seq-some-p and nil, Nicolas Petton, 2015/09/06
- Re: seq-some-p and nil, Stefan Monnier, 2015/09/06
- Re: seq-some-p and nil, Nicolas Petton, 2015/09/07
- RE: seq-some-p and nil,
Drew Adams <=
- Re: seq-some-p and nil, Stefan Monnier, 2015/09/07
- Re: seq-some-p and nil, Mark Oteiza, 2015/09/07
- RE: seq-some-p and nil, Drew Adams, 2015/09/07
- Re: seq-some-p and nil, Nicolas Petton, 2015/09/07
- Re: seq-some-p and nil, Stefan Monnier, 2015/09/07
- Re: seq-some-p and nil, Nicolas Petton, 2015/09/08
- Re: seq-some-p and nil, Stefan Monnier, 2015/09/08
- Re: seq-some-p and nil, Nicolas Petton, 2015/09/08
- Re: seq-some-p and nil, Stefan Monnier, 2015/09/08
- Re: seq-some-p and nil, David Kastrup, 2015/09/08