help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to mapcar or across a list?


From: John Mastro
Subject: Re: How to mapcar or across a list?
Date: Wed, 15 Jul 2015 15:21:39 -0700

> so here's my problem: I have a list of Boolean values, and I want to
> `mapcar' an `or' across it (IOW, I want to test whether at least one of
> them is true).  Of course, (apply #'or my-list) does not work.  Of
> course, I can (cl-reduce (lambda (x y) (or x y)) my-list) -- but is
> there a better method?

You've already gotten good answers from others but, for the sake of one
more option, you could also accomplish this with `cl-loop' (which, of
course, some love and some hate).

It would end up looking something like:

(cl-loop for item in list
         thereis (your-predicate item))

If the predicate would be `(not (null item))', you can drop it entirely
(as you would expect):

(cl-loop for item in list thereis item)

-- 
john



reply via email to

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