Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
First macro
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
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
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Luke Crook  
View profile  
 More options Jan 10 2004, 6:05 am
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wolfhard Buß  
View profile  
 More options Jan 10 2004, 9:48 am
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Luke J Crook  
View profile  
 More options Jan 11 2004, 2:17 am
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »