|
From: | Eric Abrahamsen |
Subject: | Re: return first element in list with certain property |
Date: | Sun, 19 Nov 2017 12:51:41 -0800 |
User-agent: | Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
Emanuel Berg <moasen@zoho.com> writes: > 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 I think `cl-find' is what I use for this, with the :test keyword. Or `seq-find' seems to do the same thing.
[Prev in Thread] | Current Thread | [Next in Thread] |