The group you are posting to is a
Usenet group . Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Newsgroups: comp.lang.lisp
From:
lcl... @yahoo.com (Luke Crook)
Date: 10 Jan 2004 03:04:36 -0800
Local: Sat, Jan 10 2004 6:04 am
Subject: First macro
I am attempting to write a macro that generates the clauses in a COND I do this using a mapcar..
`(cond ,@(mapcar #'(lambda (event) (cond ...)) list-of-events))
..passing it a list-of-events and having it generate the corresponding clause..
`((eql
..based on a (COND). My problem is that the lambda will return NIL when no clause is generated, obviously. mapcar then cons this result onto the result list. This tends to mess up my COND, interspersing the tests with NIL.
Is there an easy way I can have mapcar not add NIL to the list of results ? Or have the lambda not return a nil ? Or am I approaching this the wrong way ?
You must
Sign in before you can post messages.
You do not have the permission required to post.
Newsgroups: comp.lang.lisp
From:
wb... @gmx.net (Wolfhard Buß)
Date: Sat, 10 Jan 2004 15:49:18 +0100
Local: Sat, Jan 10 2004 9:49 am
Subject: Re: First macro
MAPCLAN, a MAPCAR that doesn't cons nils, also known as MAPPEND, is probably what you are looking for. (defun mapclan (function list &rest lists) (loop for args in (zip (cons list lists)) when (apply function args) collect it))
-- "Hurry if you still want to see something. Everything is vanishing." -- Paul Cézanne (1839-1906)
You must
Sign in before you can post messages.
You do not have the permission required to post.
Newsgroups: comp.lang.lisp
From:
Luke J Crook <lcl... @NO-SPAM.hd-plus.com>
Date: Sun, 11 Jan 2004 07:16:48 GMT
Local: Sun, Jan 11 2004 2:16 am
Subject: Re: First macro
Wolfhard Buß wrote:
> MAPCLAN, a MAPCAR that doesn't cons nils, also known as MAPPEND, is
> probably what you are looking for.
> (defun mapclan (function list &rest lists) > (loop for args in (zip (cons list lists)) > when (apply function args) collect it))
Thanks for the feedback. My post is actually a dupe, thanks to the delay of a couple of days when I tried to post through google . -Luke
You must
Sign in before you can post messages.
You do not have the permission required to post.