Hot answers tagged iterators
4
Table has attribute HoldAll. This means its arguments are left unevaluated:
Attributes[Table]
(* {HoldAll, Protected} *)
Using an Evaluate will force the evaluation order to be as you desire:
x = {i, 5};
Table[i, Evaluate@x]
(* {1, 2, 3, 4, 5} *)
3
Following belisarius' suggestion you might use something like:
SetAttributes[f, HoldFirst]
f[body_, n_Integer?Positive, m__:3] := Block[{a},
Do[body, ##] & @@ Thread[{Array[a, n], m}]
]
Use:
f[Print[a[1], a[2], a[3]], 3]
f[Print[a[1], a[2]], 2, 4]
f[Print[a[1], a[2]], 2, 5, 7]
How are parameters evaluated for a Plot in Manipulate
The second ...
1
Say for $n=1$, you have defined f[{i1}] as your first experiment. For $n=2$, your experiments are defined by f[{i1,i2}], for $n=3$ the experiments are defined by f[{i1,i2,i3}] and etc, with the idea that you wish to allow $n$ such experiments. If you structure your experiments this way, then you can create a list of all experiments by
m = 3; n = 3; c = ...
Only top voted, non community-wiki answers of a minimum length are eligible

