From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Rivka Miller Newsgroups: gmane.emacs.help Subject: Re: `list-of' macro snippet [regarding Comprehensions] Date: Fri, 2 Nov 2012 19:06:33 -0700 (PDT) Message-ID: References: <44777946-db62-48fa-9e99-2fd06c6d296c@g18g2000vbf.googlegroups.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1351908623 10637 80.91.229.3 (3 Nov 2012 02:10:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 3 Nov 2012 02:10:23 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Nov 03 03:10:28 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 1TUTBo-0008O6-0G for geh-help-gnu-emacs@m.gmane.org; Sat, 03 Nov 2012 03:10:24 +0100 Original-Received: from localhost ([::1]:39597 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TUTBf-0004qv-5n for geh-help-gnu-emacs@m.gmane.org; Fri, 02 Nov 2012 22:10:15 -0400 Original-Received: by 10.224.138.142 with SMTP id a14mr1943225qau.4.1351908394037; Fri, 02 Nov 2012 19:06:34 -0700 (PDT) Original-Received: by 10.52.34.205 with SMTP id b13mr719360vdj.3.1351908394011; Fri, 02 Nov 2012 19:06:34 -0700 (PDT) Original-Path: usenet.stanford.edu!c7no4019199qap.0!news-out.google.com!gf5ni18188417qab.0!nntp.google.com!c7no4019198qap.0!postnews.google.com!y6g2000vbb.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.sources, gnu.emacs.help, comp.emacs, comp.lang.lisp, comp.lang.functional Complaints-To: groups-abuse@google.com Injection-Info: y6g2000vbb.googlegroups.com; posting-host=99.61.83.205; posting-account=V5Tx-QoAAACNTDxOswIwdOklJAUE-vym Original-NNTP-Posting-Host: 99.61.83.205 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 5.1; rv:12.0) Gecko/20100101 Firefox/12.0,gzip(gfe) Injection-Date: Sat, 03 Nov 2012 02:06:34 +0000 Original-Xref: usenet.stanford.edu gnu.emacs.sources:13604 gnu.emacs.help:195197 comp.emacs:102685 comp.lang.lisp:311674 comp.lang.functional:69676 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:87526 Archived-At: This is not that hard. You can take the defmacro comp out of the defun. It should not be hard ---------------------------------------- background info in gnu.emacs.help I spent a few hours poring over and fixed some of the variables and backquotes and character codes. The defmacro is now only nested in one function where it is needed. Hope, someone can help get it to work and produce some kind of demo examples. (defun open-bracket (stream ch) (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))))))) (do ((l nil) (c (read stream t nil t)(read stream t nil t))) ((eq c '|]|) `(comp ,(reverse l) ())) (push c l)) ) (defun closing-bracket (stream ch) '|]|) (eval-when (compile load eval) (set-macro-character #\[ #'open-bracket) (set-macro-character #\] #'closing-bracket))