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

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

return first element in list with certain property


From: Emanuel Berg
Subject: return first element in list with certain property
Date: Sun, 19 Nov 2017 21:43:56 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

What is considered the right way to return the
first element in list that has
a certain property?

The best way I've found so far is `cl-some' and
then `and'. While I don't consider the
"`and' hack" to be detrimental in any way I was
curious if there was a complete
"hack free" way...

Example: get the first element that is bigger
than 1:

    (cl-some (lambda (e) (and (> e 1) e)) '(1 1 3 1 4 2)) ; 3

-- 
underground experts united
http://user.it.uu.se/~embe8573




reply via email to

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