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:20:35 +0100 Organization: Aioe.org NNTP Server Message-ID: <844lpqq82k.fsf@gmail.com> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1511126732 18126 195.159.176.226 (19 Nov 2017 21:25:32 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 19 Nov 2017 21:25:32 +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:25:29 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 1eGX5j-0004Q8-Jm for geh-help-gnu-emacs@m.gmane.org; Sun, 19 Nov 2017 22:25:27 +0100 Original-Received: from localhost ([::1]:54435 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGX5q-0000jE-UF for geh-help-gnu-emacs@m.gmane.org; Sun, 19 Nov 2017 16:25:34 -0500 X-Received: by 10.223.153.86 with SMTP id x80mr883368wrb.27.1511126435829; Sun, 19 Nov 2017 13:20:35 -0800 (PST) Original-Path: usenet.stanford.edu!b72no1780701wmd.0!news-out.google.com!a84ni8593wmc.0!nntp.google.com!proxad.net!feeder1-2.proxad.net!news.mixmin.net!aioe.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 22 Original-NNTP-Posting-Host: ls+YiJffrWiJBEb7q1IDTg.user.gioia.aioe.org Original-X-Complaints-To: abuse@aioe.org Cancel-Lock: sha1:D2IoNHPViihTSDrH/c3+iLX4PE4= X-Notice: Filtered by postfilter v. 0.8.2 Original-Xref: usenet.stanford.edu gnu.emacs.help:220877 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:114987 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