Extending dolist

For the Compleat Fan
Locked
Jeremy Dunn
Posts: 95
Joined: Wed Oct 13, 2004 8:02 pm
Location: Bellingham WA

Extending dolist

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

eddier
Posts: 289
Joined: Mon Oct 07, 2002 2:48 pm
Location: Blue Mountain College, MS US

Post by eddier »

I use map for those occasions.

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

eddie

Locked