From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "rgb" Newsgroups: gmane.emacs.help Subject: Re: Function binders in Elisp? Date: 18 Apr 2005 09:26:12 -0700 Organization: http://groups.google.com Message-ID: <1113841572.737369.303390@l41g2000cwc.googlegroups.com> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: sea.gmane.org 1113841702 2622 80.91.229.2 (18 Apr 2005 16:28:22 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 18 Apr 2005 16:28:22 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Apr 18 18:28:16 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DNZ4c-0004qV-0j for geh-help-gnu-emacs@m.gmane.org; Mon, 18 Apr 2005 18:26:10 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DNZ8k-00071N-Fb for geh-help-gnu-emacs@m.gmane.org; Mon, 18 Apr 2005 12:30:26 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!l41g2000cwc.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 31 Original-NNTP-Posting-Host: 198.74.20.77 Original-X-Trace: posting.google.com 1113841578 32292 127.0.0.1 (18 Apr 2005 16:26:18 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Mon, 18 Apr 2005 16:26:18 +0000 (UTC) User-Agent: G2/0.2 Complaints-To: groups-abuse@google.com Injection-Info: l41g2000cwc.googlegroups.com; posting-host=198.74.20.77; posting-account=C7LM4w0AAAD23IRuMuUUJVCLQTuHhTK8 Original-Xref: shelby.stanford.edu gnu.emacs.help:130212 Original-To: help-gnu-emacs@gnu.org 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:25779 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:25779 PT wrote: > For predicates I usually use lambda functions. For example: > > (require 'cl) > (remove-if (lambda (x) (> x 2)) > '(1 2 3 4)) > > I'm not a lisp guru, therefore I often wonder if there are standard binder > functions in emacs lisp like for example bind2nd in C++ STL which > transforms a binary function into an unary function: > > find_if(L.begin(), L.end(), bind2nd(greater(), 2)) // C++ > > So that I can write something like this: > > (remove-if (bind-second '< 2) > '(1 2 3 4)) So you are looking to do this? (defmacro bind-second (first &rest others) `(lambda (x) (,first x ,@others))) (remove-if (bind-second > 2) '(1 2 3 4)) I'd think that would make the code a bit more confusing to read. But maybe it's just me.