4

I have $\vec k=(k_1,k_2,...,k_d)$, where $d$ is variable. I want to construct a table that iterates $a_i$ from $0$ to $k_i$, over a function of $\vec k$ and $\vec a$. Here is what I did (here $k$ will vary):

k = {1, 2, 3};
d = Length[k];
A = Array[Subscript[a, #] &, {d}];
ran = Transpose[{A, ConstantArray[0, d], k}]

which outputs $\{\{a_1,0,1\},\{a_2,0,2\},\{a_3,0,3\}\}$. I wish to make a table like

Table[f[k,A], ran]

but this fails because the outermost curly brackets in 'ran' don't belong. How do I remove them? I tried using the function Row (see trick used here), but I couldn't convert it back into the table.

David Raveh
  • 163
  • 6

2 Answers2

5

Perhaps this?:

Table[f[k,A], ##]& @@ ran
Michael E2
  • 235,386
  • 17
  • 334
  • 747
2

An alternative to the accepted answer:

Table[f[k, A], Sequence @@ ran // Evaluate]

Sequence @@ ran replaces a list by a sequence, so effectively removes the outermost curly brackets. Evaluate is needed because Table has the attribute HoldAll, so we need to force evaluation.

Stephen Powell
  • 1,061
  • 5
  • 13