The following simple code of course works:
Table[n^2, {n, 3, 15, 2}]
(* Out: {9, 25, 49, 81, 121, 169, 225} *)
I would then like to construct the iterator programmatically. However, the following approach does not work:
d = {n, 3, 15} (* Out: {n, 3, 15} *)
a = Append[d, 2] (* Out: {n, 3, 15, 2} *)
Table[n^2, a]
Error: Non-list iterator
aat position 2 does not evaluate to a real numeric value.
How can I avoid that error?
Evaluate, for variable iterator lists.d = {n, 3, 15}; a = Append[d, 2]; Table[n^2, Evaluate[a]]– flinty Jan 27 '22 at 11:02