From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Marco Wahl Newsgroups: gmane.emacs.help Subject: Re: return first element in list with certain property Date: Sun, 19 Nov 2017 22:19:02 +0100 Organization: Aioe.org NNTP Server Message-ID: <84a7ziq855.fsf@gmail.com> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1511126428 17733 195.159.176.226 (19 Nov 2017 21:20:28 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 19 Nov 2017 21:20:28 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Nov 19 22:20:24 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eGX0q-0004Kq-4g for geh-help-gnu-emacs@m.gmane.org; Sun, 19 Nov 2017 22:20:24 +0100 Original-Received: from localhost ([::1]:54410 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGX0x-0006OR-Fu for geh-help-gnu-emacs@m.gmane.org; Sun, 19 Nov 2017 16:20:31 -0500 Original-Path: usenet.stanford.edu!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 25 Original-NNTP-Posting-Host: ls+YiJffrWiJBEb7q1IDTg.user.gioia.aioe.org Original-X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 Cancel-Lock: sha1:Bc2asG2bN45jKZaA8o7KHrd6R9g= Original-Xref: usenet.stanford.edu gnu.emacs.help:220876 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:114986 Archived-At: Emanuel Berg 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 (cl-loop for e in '(1 1 3 1 4 2) when (> e 1) return e) lgtm