|
From: | Emanuel Berg |
Subject: | Re: Testing whether a list contains at least one non-nil element |
Date: | Tue, 25 Oct 2022 14:12:33 +0200 |
User-agent: | Gnus/5.13 (Gnus v5.13) |
Jean Louis wrote: >> I would like to test whether a list contains at least one >> non-nil element? If I do that, then I would be able to >> continue a loop where a non-nil element would mean that >> a match was found. > > Here is the test for non nil element: > > (elt (delq nil (list nil nil)) 0) ⇒ nil > > (elt (delq nil (list nil 1)) 0) ⇒ 1 Interesting question ... (cl-position-if (lambda (e) e) '(nil nil)) ; nil (cl-position-if (lambda (e) e) '(nil 1)) ; 1 -- underground experts united https://dataswamp.org/~incal
[Prev in Thread] | Current Thread | [Next in Thread] |