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 ?
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)
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