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

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

Re: return first element in list with certain property


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

Marco Wahl wrote:

>> 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
>
> (cl-loop for e in '(1 1 3 1 4 2) when (> e 1)
> return e)

Much worse than mine :)

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




reply via email to

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