help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [External] : Re: Testing whether a list contains at least one non-ni


From: Emanuel Berg
Subject: Re: [External] : Re: Testing whether a list contains at least one non-nil element
Date: Wed, 26 Oct 2022 19:43:22 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Drew Adams wrote:

>>> (cl-member-if-not #'null toto)
>> 
>> Close
>>   (cl-member-if-not #'null '(nil nil)) ; nil
>>   (cl-member-if-not #'null '(nil 2))   ; (2)
>> 
>> But
>>   (cl-position-if-not #'null '(nil nil)) ; nil
>>   (cl-position-if-not #'null '(nil 2))   ; 1
>
> The request was for a test of whether the input
> list contains any non-nil elements.

Right, I thought the question was identify the spot and loop
the rest of the list from there, and the OP said something to
that extend, but actually it's unclear what solution is best
even then since one can iterate the rest of the list with
`member' as well, and maybe that's even more idiomatic than to
rely on an index to identify the starting point come think
of it.

Okay I was wrong ...

https://www.youtube.com/watch?v=6WOYnv59Bi8

> Yes, both `cl-member-if-not' and `cl-position-if-not' can do
> that. Or `cl-member-if' and `cl-position-if', passing
> #'identity.
>
> There are lots of ways to do it.

That's a good thing, but which way is the best way?

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]