We have a number of clauses (condition body) which we want to give to cond
, like so:
(cond (condition1 body1)
(condition2 body2)
(condition3 body3))
But imagine that the clauses were first generated via mapcar
, which gave the following list:
((condition1 body1)
(condition2 body2)
(condition3 body3))
Let's say that the above list is the content of variable clauses
.
Now, we would like to pass it to cond
, but if we do the following:
`(cond ,clauses)
it results in:
(cond ((condition1 body1)
(condition2 body2)
(condition3 body3)))
which does not work, instead of:
(cond (condition1 body1)
(condition2 body2)
(condition3 body3))
Is there a way around this problem ?
mapcar
-ing down the list ofclauses
and test each condition during that process (you can use acatch
andthrow
done once a condition tests positive to stop themapcar
dead in its tracks), instead of trying to force it into a particular format of(cond (. . .
?