|
From: | Emanuel Berg |
Subject: | Re: [External] : Re: Testing whether a list contains at least one non-nil element |
Date: | Fri, 28 Oct 2022 02:22:52 +0200 |
User-agent: | Gnus/5.13 (Gnus v5.13) |
Jean Louis wrote: > (defun check-if-any-elt-is-non-nil (list) > (let (there-is) > (while (and list (not there-is)) > (when (car list) (setq there-is t)) > (setq list (cdr list))) > there-is)) (require 'cl-lib) (defun has-non-nil (lst) (cl-loop for e in lst until e finally return e) ) (benchmark 10000000 (has-non-nil (append (list 1) (make-list 1000000 nil)))) ; "Elapsed time: 0.330502s" (benchmark 10000000 (has-non-nil (append (make-list 1000000 nil)))) ; "Elapsed time: 0.570150s" -- underground experts united https://dataswamp.org/~incal
[Prev in Thread] | Current Thread | [Next in Thread] |