4
$\begingroup$

Let $P=\{p_1,...p_n\}$. I would like a way to implent Table[Expression,{$p_1$,lim},{$p_2$,lim},...,{$p_n$,lim}] where n and lim are parameters defined by the user. Any ideas?

$\endgroup$
4
  • 4
    $\begingroup$ Could you provide minimal example? $\endgroup$
    – Kuba
    Commented Jun 25, 2014 at 19:51
  • $\begingroup$ This seems very familiar, assuming my interpretation is correct, but I can't find the original. Help, anyone? $\endgroup$
    – Mr.Wizard
    Commented Jun 26, 2014 at 2:03
  • $\begingroup$ @Mr.Wizard I agree it seems familiar. This is the closest I've found: 5056 $\endgroup$
    – Michael E2
    Commented Jun 26, 2014 at 4:24
  • 1
    $\begingroup$ This question was closed and due for deletion. I feel that it could be useful as a redirect so I am marking it as a duplicate instead, even though the "original" is about Sum rather than Table. $\endgroup$
    – Mr.Wizard
    Commented Jun 27, 2015 at 9:55

2 Answers 2

1
$\begingroup$

One liner:

Table[expr,Evaluate[Sequence@@({#,lim}&/@Array[Subscript[p, #] &, n])]]
$\endgroup$
1
  • $\begingroup$ Exactly what I needed! Thanks! $\endgroup$
    – Heterotic
    Commented Jun 26, 2014 at 8:37
0
$\begingroup$
p0 = Array[Subscript[p, #] &, 7]  
l0 = Table[1 + Mod[i, 3], {i, 7}]  
Table[q, Evaluate[Sequence @@ Transpose[{p0, l0}]]]
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.