From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Pascal J. Bourguignon" Newsgroups: gmane.emacs.help Subject: Re: `list-of' macro snippet [regarding Comprehensions] Date: Wed, 07 Nov 2012 23:30:44 +0100 Organization: Informatimago Message-ID: <87r4o56o6j.fsf@informatimago.com> References: <44777946-db62-48fa-9e99-2fd06c6d296c@g18g2000vbf.googlegroups.com> <87pq3vmlg5.fsf@informatimago.com> <556673a6-b350-49cc-905d-0662222ca071@g8g2000yqp.googlegroups.com> <3445356f-5bb8-4dcd-bd45-d98a4e103a2a@g18g2000vbf.googlegroups.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1352327716 5018 80.91.229.3 (7 Nov 2012 22:35:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 7 Nov 2012 22:35:16 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 07 23:35:26 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TWEDV-0001nk-DV for geh-help-gnu-emacs@m.gmane.org; Wed, 07 Nov 2012 23:35:25 +0100 Original-Received: from localhost ([::1]:54133 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TWEDM-00047S-7f for geh-help-gnu-emacs@m.gmane.org; Wed, 07 Nov 2012 17:35:16 -0500 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.sources, gnu.emacs.help, comp.emacs, comp.lang.lisp, comp.lang.functional Original-Lines: 35 Original-X-Trace: individual.net 7lCC/H1+CcOP/C6SWA11iA6pWYPE37aEEGK0Tu0wfM1wn/sYsQvhBG3JtwjIg4s6qU Cancel-Lock: sha1:Mzc0ZjgxNjU5YzIyZmZjYThjY2ZiZTJjODMwZGM2NDY1OGFkZDg1Mg== sha1:W5ha7v+uEMIqoDWMwS50Fcg70sg= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (darwin) Original-Xref: usenet.stanford.edu gnu.emacs.sources:13617 gnu.emacs.help:195251 comp.emacs:102701 comp.lang.lisp:311784 comp.lang.functional:69686 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:87579 Archived-At: Rivka Miller writes: > I still need someone to help me get the common-lisp comprehension code > working on emacs. Require cl and use defmacro* instead of defmacro: (require 'cl) (defmacro* comp ((e &rest qs) l2) (if (null qs) `(cons ,e ,l2) ; rule A (let ((q1 (car qs)) (q (cdr qs))) (if (not(eq (cadr q1) '<-)) ; a generator? `(if ,q1 (comp (,e ,@q),l2) ,l2) ; rule B (let ((v (car q1)) ; rule C (l1 (third q1)) (h (gentemp "H-")) (us (gentemp "US-")) (us1 (gentemp "US1-"))) `(labels ((,h (,us) ; corresponds to a letrec (if (null ,us) ,l2 (let ((,v (car ,us)) (,us1 (cdr ,us))) (comp (,e ,@q) (,h ,us1)))))) (,h ,l1))))))) (macroexpand '(comp (e (< 1 2)) l2)) --> (if (< 1 2) (comp (e) l2) l2) (macroexpand '(comp (e) l2)) --> (cons e l2) -- __Pascal Bourguignon__ http://www.informatimago.com