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: Sat, 29 Oct 2022 11:20:10 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Michael Heerdegen wrote:

>> 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.

He knows that ...
>
-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

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