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: Drew Adams
Subject: RE: [External] : Re: Testing whether a list contains at least one non-nil element
Date: Tue, 25 Oct 2022 20:15:25 +0000

> > > 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.
> >
> > (seq-some (lambda (e) (not (null e))) mylist)
> >
> > or shorter:
> >
> > (not (seq-every-p #'null mylist))
> 
> How does your implementation (not (seq-every-p #'null mylist)) compared to
> 
> (elt (delq nil mylist) 0)

`delq' is a "destructive" operation.  It can, and
generally does, modify list structure.  Is that what
you intend?  That's something other than just doing
a "test whether a list contains at least one non-nil
element."

Be very careful and know what you're doing, and why,
if you start writing code that modifies list structure.


reply via email to

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