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

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

Re: Testing whether a list contains at least one non-nil element


From: Emanuel Berg
Subject: Re: Testing whether a list contains at least one non-nil element
Date: Tue, 25 Oct 2022 14:15:17 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Michael Heerdegen wrote:

>> I would like to test whether a list contains at least one
>> non-nil element?
>
> I'd use `cl-some': (cl-some #'identity my-list).

Cute, and `identity' also works with `cl-position-if' ...

(cl-some #'identity '(nil nil)) ; nil
(cl-some #'identity '(nil 1))   ; 1

(cl-position-if #'identity '(nil nil)) ; nil
(cl-position-if #'identity '(nil 1))   ; 1

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




reply via email to

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