From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mike Mattie Newsgroups: gmane.emacs.help Subject: Re: fif function from On Lisp Date: Wed, 5 Mar 2008 16:34:33 -0800 Message-ID: <20080305163433.21c18db8@reforged> References: <5ac4de71-b4e5-4b3d-997c-e438b816740e@d4g2000prg.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/5_ZsPi8PFmTch6Lvj6fSCqO"; protocol="application/pgp-signature"; micalg=PGP-SHA1 X-Trace: ger.gmane.org 1204764158 7355 80.91.229.12 (6 Mar 2008 00:42:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 6 Mar 2008 00:42:38 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Mar 06 01:43:04 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 1JX4CI-0000aW-8Z for geh-help-gnu-emacs@m.gmane.org; Thu, 06 Mar 2008 01:42:58 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JX4Bk-0001LF-O5 for geh-help-gnu-emacs@m.gmane.org; Wed, 05 Mar 2008 19:42:24 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JX4BU-0001L6-5o for help-gnu-emacs@gnu.org; Wed, 05 Mar 2008 19:42:08 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JX4BS-0001Km-In for help-gnu-emacs@gnu.org; Wed, 05 Mar 2008 19:42:07 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JX4BS-0001Kj-E5 for help-gnu-emacs@gnu.org; Wed, 05 Mar 2008 19:42:06 -0500 Original-Received: from wa-out-1112.google.com ([209.85.146.178]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JX4BR-0002eh-Ur for help-gnu-emacs@gnu.org; Wed, 05 Mar 2008 19:42:06 -0500 Original-Received: by wa-out-1112.google.com with SMTP id k34so2102743wah.10 for ; Wed, 05 Mar 2008 16:42:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:subject:message-id:in-reply-to:references:x-mailer:mime-version:content-type; bh=XIGrxTHtE/WtOo+nOHibJ4sNK28axfmpvXBGVRHcuQQ=; b=hwI1TOE5BPtfEQib6EJ7HyPFNsTpLTe7XBKjCrHitiHyMQeobGDDpKtWoegYBkyfIUO0N6BnH/p4KLW8qUyVUMnljfloL1Fw4mD3eNajCyENs7f9IlM7++uWfGhzllPGRDnCkX0CLSCIsk40f+K2R+UgZ22kb2QnCyvcOCjwFWY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:in-reply-to:references:x-mailer:mime-version:content-type; b=lX504T7/Nd9skTY7aSUpy/aBQl84lg3RdpdOrwntBnaolKRNblfmUtoWO1nkEt8KCO6IDhcytWl4vMX6Whm0UE5qWQvh+eYacP052+jKV40D8jpCL+GvVBzpeA8XJbjp+IEasqsHOw+ksvarP1oh4o09tmpGbfNQrD3tVn+8WCs= Original-Received: by 10.114.152.17 with SMTP id z17mr5658327wad.128.1204764123140; Wed, 05 Mar 2008 16:42:03 -0800 (PST) Original-Received: from reforged ( [71.217.206.83]) by mx.google.com with ESMTPS id c26sm3146524waa.35.2008.03.05.16.42.01 (version=SSLv3 cipher=OTHER); Wed, 05 Mar 2008 16:42:02 -0800 (PST) In-Reply-To: <5ac4de71-b4e5-4b3d-997c-e438b816740e@d4g2000prg.googlegroups.com> X-Mailer: Claws Mail 3.0.2 (GTK+ 2.12.5; i686-pc-linux-gnu) X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) 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:52080 Archived-At: --Sig_/5_ZsPi8PFmTch6Lvj6fSCqO Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Tue, 4 Mar 2008 04:31:19 -0800 (PST) weber wrote: > Hi folks. > For some reason this function from On Lisp doesn't work: >=20 > (defun fif (a b &optional c) > '(lambda (x) > (if (funcall a x) > (funcall b x) > (unless (null c) (funcall c x))))) >=20 > I should be able to call it like this: >=20 > (mapcar (fif 'zerop '1+ 1-) '(0 1 2 3) =3D> (1 0 1 2) >=20 > but i'm probably missing something that is differs from Common Lisp to > Elisp. >=20 > Thanks in advance, > weber (require 'cl) (defun plus (x) (+ x 1)) (defun minus (x) (- x 1)) (defun fif (a b &optional c) (lexical-let ((a-fn a) (b-fn b) (c-fn c)) (lambda (x) (if (funcall a-fn x) (funcall b-fn x) (if (functionp c-fn) (funcall c-fn x)))))) (mapcar (fif 'zerop 'plus 'minus) '(0 1 2 3)) ;; =3D> (1 0 1 2) This works here. Cheers, Mike Mattie --Sig_/5_ZsPi8PFmTch6Lvj6fSCqO Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFHzzwZdfRchrkBInkRAik+AKCtD4HWQy95h3MZv4u01XBuCen00QCgp/97 y5JJP355Y/4lQxgdPY5Z/Vc= =/f7L -----END PGP SIGNATURE----- --Sig_/5_ZsPi8PFmTch6Lvj6fSCqO--