From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "Robert L." Newsgroups: gmane.emacs.help Subject: Re: return first element in list with certain property Date: Tue, 6 Mar 2018 00:31:14 +0000 (UTC) Organization: Aioe.org NNTP Server Message-ID: References: <8660a60zjn.fsf@zoho.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 X-Trace: blaine.gmane.org 1520296412 20472 195.159.176.226 (6 Mar 2018 00:33:32 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 6 Mar 2018 00:33:32 +0000 (UTC) User-Agent: XanaNews/1.18.1.6 To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Mar 06 01:33:28 2018 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 1et0Xg-0003y9-Vp for geh-help-gnu-emacs@m.gmane.org; Tue, 06 Mar 2018 01:33:21 +0100 Original-Received: from localhost ([::1]:52283 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1et0Zj-0001tc-Ji for geh-help-gnu-emacs@m.gmane.org; Mon, 05 Mar 2018 19:35:27 -0500 X-Received: by 10.28.178.80 with SMTP id b77mr1237377wmf.5.1520296277476; Mon, 05 Mar 2018 16:31:17 -0800 (PST) Original-Path: usenet.stanford.edu!139no3679783wmp.0!news-out.google.com!194ni44663wmv.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: 28 Original-NNTP-Posting-Host: NWN9vo+LOIdN+NLLXKe0pA.user.gioia.aioe.org Original-X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.3 Original-Xref: usenet.stanford.edu gnu.emacs.help:221996 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:116111 Archived-At: On 11/19/2017, Philipp Stephani wrote: > Emanuel Berg schrieb am So., 19. Nov. 2017 um 21:44 Uhr: > > > 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... > > > > cl-find-if (defun list-find-if (pred xs) (while (and (consp xs) (not (funcall pred (car xs)))) (pop xs)) (car xs)) -- The report card by the American Society of Civil Engineers showed the national infrastructure a single grade above failure, a step from declining to the point where everyday things simply stop working the way people expect them to. http://archive.org/details/nolies