Consider the following:
Table[Table[x = 20; y = 30; 2 i x + 3 j y , {i, 10}], {j, 3}]
Suppose I want the result of this nested Table to be stored to an appendable file, I could do something like:
Table[Table[x = 20; y = 30; 2 i x + 3 j y >> test.dat, {i, 10}], {j, 3}]
Where test.dat
has been previously opened using OpenAppend["test.dat"]
However, this doesn't work as I would like it to as the answer is stored differently than the actual output shown below and Mathematica returns Null for every element of the output.
{
{130, 170, 210, 250, 290, 330, 370, 410, 450, 490}, {220, 260, 300,
340, 380, 420, 460, 500, 540, 580}, {310, 350, 390, 430, 470, 510,
550, 590, 630, 670}
}
My question is this. How can I save the output of the Nested Table to a file for every iteration of the outer Table
and prevent any List
from being returned by Mathematica?. That is, I don't want Mathematica to return the following List
as it currently does:
{ {Null, Null, Null, Null, Null, Null, Null, Null, Null, Null}, {Null,
Null, Null, Null, Null, Null, Null, Null, Null, Null}, {Null, Null,
Null, Null, Null, Null, Null, Null, Null, Null} }
I will also like the data stored in the file to be exactly as the output shown above, since I will use it for further calculations in Mathematica. This is basically a way to prevent excessive memory usage. If there are better ways to achieve the same thing please feel free to post that as an answer.
Table
! UseDo
instead. Incidentally, there is no reason to nest these functions. They both support multiple iterators. $\endgroup$With[{x = 20, y = 30}, Table[2 i x + 3 j y, {j, 3}, {i, 10}]]
for what you want. $\endgroup$