newLISP Fan Club

Forum => Anything else we might add? => Topic started by: Jeremy Dunn on February 04, 2005, 01:20:56 PM

Title: Extending dolist
Post by: Jeremy Dunn on February 04, 2005, 01:20:56 PM
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?
Title:
Post by: eddier on February 04, 2005, 02:27:44 PM
I use map for those occasions.



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

 X Y)



eddie