From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: What to use instead of find-if? Date: Mon, 1 Dec 2008 13:24:19 -0800 Message-ID: <007b01c953fb$2dc37250$c2b22382@us.oracle.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1228166698 18171 80.91.229.12 (1 Dec 2008 21:24:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 1 Dec 2008 21:24:58 +0000 (UTC) To: "'Rupert Swarbrick'" , Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Dec 01 22:26:02 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1L7GHI-0006ly-Tr for geh-help-gnu-emacs@m.gmane.org; Mon, 01 Dec 2008 22:26:01 +0100 Original-Received: from localhost ([127.0.0.1]:57902 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L7GG8-0002lM-MS for geh-help-gnu-emacs@m.gmane.org; Mon, 01 Dec 2008 16:24:48 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L7GFr-0002lH-H8 for help-gnu-emacs@gnu.org; Mon, 01 Dec 2008 16:24:31 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L7GFq-0002l5-4v for help-gnu-emacs@gnu.org; Mon, 01 Dec 2008 16:24:31 -0500 Original-Received: from [199.232.76.173] (port=56915 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L7GFp-0002l2-Vy for help-gnu-emacs@gnu.org; Mon, 01 Dec 2008 16:24:30 -0500 Original-Received: from acsinet11.oracle.com ([141.146.126.233]:33481) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L7GFp-00013M-FK for help-gnu-emacs@gnu.org; Mon, 01 Dec 2008 16:24:29 -0500 Original-Received: from rgminet15.oracle.com (rcsinet15.oracle.com [148.87.113.117]) by acsinet11.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id mB1LPCfV009686 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 1 Dec 2008 21:25:14 GMT Original-Received: from acsmt707.oracle.com (acsmt707.oracle.com [141.146.40.85]) by rgminet15.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id mB1LOR8p026123; Mon, 1 Dec 2008 21:24:28 GMT Original-Received: from dradamslap1 (/130.35.178.194) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Dec 2008 13:24:19 -0800 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.3350 Thread-Index: AclT9UBw/oLYEIU5TTqA47v68mQpYAABUqYA X-Source-IP: acsmt707.oracle.com [141.146.40.85] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090204.49345605.0166:SCFSTAT928724,ss=1,fgs=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 1) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:60298 Archived-At: > So the code I'm thinking about does the following: > (let ((blah (find-if (lambda (elem) > (whopping-great-predicatey-thing)) > some-list))) > (if blah (something using blah) (something else))) > > Can anyone suggest a vaguely idiomatic way to do this using > the built-in constructs of elisp? There are no doubt lots of ways to do it. Here's one: (defun my-find-if (pred xs) (catch 'my-found (dolist (x xs) (when (funcall pred x) (throw 'my-found x))) nil))