I have:
myres = {};
Do[
Do[
Append[myres, {j, i}], {i, 1, 3}
],
{j, 1, 5}
]
However, when I run the code and then enter:
myres
I get:
(* { } *)
Why is it empty? Can someone explain my misunderstanding? Also, could someone suggest some lines in the code that will show some intermediate results as to what is happening?
myres = Append[myres, {j, i}]. Of course, AppendTo is more efficient. And yes, I like Table better as well, but I am trying to work on some procedural programming style. – David Dec 06 '15 at 06:44AppendTois not efficient, try to run your program withAppendTofor sayi=300,j=500. And then tryTablewith same values. Mathematica has some inherent problems, like any other system. – Pankaj Sejwal Dec 06 '15 at 06:46SowandReapcan be more useful thanTablein more complicated cases (e.g., if a list item in not always generated in each iteration). – Michael E2 Dec 06 '15 at 14:45