The following code:
Table[i*j, Apply[Sequence , {{i, 1, 3}, {j, 1, 2}}]]
returns the error:
Table::nliter: Non-list iterator Sequence@@{{i,1,3},{j,1,2}} at position 2 does not evaluate to a real numeric value.
On the other hand, the following alternative (which should be completely equivalent) works fine:
Table[i*j, Sequence[{i, 1, 3}, {j, 1, 2}]]
My questions:
- Why is the first version not working while the last one is?
- How can I make the first line work in the simplest manner possible?
This is a subroutine I would need for a more complicated function.
MemberQ[Attributes[Table], HoldAll]
givesTrue
, so you need to doTable[i*j, Evaluate[Apply[Sequence, {{i, 1, 3}, {j, 1, 2}}]]]
. $\endgroup$