Re: Handling deep list recursion

Heime <[email protected]>
Newsgroups gmane.emacs.help
Message-ID <mCmA24pRJ3H1nIBAYIWP4saYevv7KMlpAdfx3MV3PFfPbpbfJivXe2r1NItBy077vRTqD69bcS9-fZRSMjNx0pIpuKBec5fNdYl2bqnzvm4=@protonmail.com>



Sent with Proton Mail secure email.

On Tuesday, April 14th, 2026 at 11:43 AM, Heime <[email protected]> wrote:

> 
> On Tuesday, April 14th, 2026 at 11:12 AM, [email protected] <[email protected]> wrote:
> 
> > Heime <[email protected]> writes:
> >
> > > I want to handle the recursion situation when list is too big.
> > > What would be the best plan when it is too long?  Catch the error
> > > if it happens and continue with nonlocal exit than continues with
> > > cl-every?  Of compute the length beforehand?
> > >
> >
> > 1. If someone does not provide a recursive solution to your
> > question, then you might consider writing an iterative
> > solution using ‘dolist’ or ‘while’ or ‘do’.
> 
> I could use the `while' approach, because there is no binding
> overhead.
> 
> >    (info "(elisp) Iteration")
> >
> > 2. Besides ‘cl-every’, you could write a solution using
> > ‘cl-find-if’ or ‘cl-find-if-not’ or ‘cl-notany’.
> 
> cl-notany looks the most appropriate because it exits immediately
> on first non-consp cell, matching the recursive early-return logic.

Is this equivalent to (cl-every #'consp object)?  Does cl-notany
return immediately as soon as an entry is not a consp?

      (cl-notany (lambda (x) (not (consp x))) object)


 
> > --
> > The lyf so short, the craft so long to lerne.
> > - Geoffrey Chaucer, The Parliament of Birds.
> >
> >
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.