# Do Loop For Sets of Variables

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.

• Why not something like Table[g[a, b] /. Thread[{a, b} -> list], {list, {{1, 2}, {3, 4}}}]? Mar 30 '18 at 11:52
• @J.M. Thank you for your comment. I cannot use such structure because the variables are parameters inside a large function. In each loop I want to update specific parameters to specific values, while keeping other parameters the same. Mar 30 '18 at 11:55
• Based on this and your other question, I have the nagging suspicion that you've chosen an architecture that is making simple substitutions and looping more complicated than it has to be. Mar 30 '18 at 11:59
• @J.M. here is my code: dropbox.com/s/bfbfstrsbmorjvy/… Mar 30 '18 at 12:08
• What about list = {};Do[list = AppendTo[list,x],{x,{{1,2},{3,4}}];? Note however that using Append in loops will slow things down considerably as it involves a lot of copy operations. Solutions based on Sow and Reap (or even better: InternalBag) should yield better performance. Mar 30 '18 at 12:14

1. Pass a list of parameter-tuples to Table
Table[
`