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: Michael Heerdegen
Subject: Re: [External] : Re: Testing whether a list contains at least one non-nil element
Date: Fri, 28 Oct 2022 08:20:45 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

<tomas@tuxteam.de> writes:

> If you are doing it "by hand", why not indulge in Lisp's
> "classic elegance", like so:
>
>   (defun has-non-nil (lst)
>     (cond
>      ((null lst) nil)
>      ((consp lst) (or (not (null (car lst))) (has-non-nil (cdr lst))))
>      (t (error "Not a proper list! You cheater!"))))

You don't want to implement such functions in Emacs with recursion
because you'll easily hit `max-lisp-eval-depth' when they are called.
Sorry to tell you, but a loop is the preferable way in Elisp.

Michael.




reply via email to

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