Page 1 of 1

Extending dolist

Posted: Fri Feb 04, 2005 9:20 pm
by Jeremy Dunn
I occasionally run across situations where I want dolist to set more than one variable for more than one list. Suppose we have two lists

L1 (a b c ... n)
L2 (A B C... N)

I would like to be able to write something like

(dolist ('(X Y) L1 L2)
<dostuff here>
)

where sequentially X would be set to a,b,c... and Y to A,B,C...

I would also like to write

(dolist (X L1 L2)
<dostuff here>
)

where X would sequentially be set to a series of lists (a A)(b B) ...

Is there some elegant way of doing these that I am unaware of?

Posted: Fri Feb 04, 2005 10:27 pm
by eddier
I use map for those occasions.

(map (fn (x y) (whatever with x and y))
X Y)

eddie