If I want to have a nested list like 10 times of {1,2..,9,10}
:
{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, {1,
2, 3, 4, 5, 6, 7, 8, 9, 10}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, {1,
2, 3, 4, 5, 6, 7, 8, 9, 10}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, {1, 2,
3, 4, 5, 6, 7, 8, 9, 10}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, {1, 2,
3, 4, 5, 6, 7, 8, 9, 10}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}}
I can easily understand that Table[i,{i,1,10}]
will give me a sub list {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
, so I can imagine if I want to have ten same sub lists I need to apply this table function for ten times, so I use Table[Table[i,{i,1,10}],{10}]
to get what I want.
But I know for the language of Mathematica, things could happen a lot of miraculous than I thought, there must be some more elegant ways to manipulate lists. My question is asking do you think 'Table[Table[expr, ],{conditions}]' stuff are good implementations in terms of efficiency in my case?
Table
is likely pretty efficient, barring the lists having special structure (like the example you showed). However, you don't need to nestTable
s: You can just doTable[i, {10}, {i, 1, 10}]
, for instance. $\endgroup$