Can I create a Do
loop where instead of varying only 1 variable, I vary multiple sets of variable ?
For example (the syntax is invented and only serves as a purpose to show what I mean):
list = {}
Do[
list = AppendTo[list,{a,b}],
{a,b,{{1,2},{3,4}}];
should give me
list
{{1,2},{3,4}}
I really need to loop over the variables.
Table[g[a, b] /. Thread[{a, b} -> list], {list, {{1, 2}, {3, 4}}}]
? $\endgroup$list = {};Do[list = AppendTo[list,x],{x,{{1,2},{3,4}}];
? Note however that usingAppend
in loops will slow things down considerably as it involves a lot of copy operations. Solutions based onSow
andReap
(or even better:Internal`Bag
) should yield better performance. $\endgroup$