Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
$\begingroup$you could do something like ToExpression[StringJoin["p",ToString[#]]]&/@Range[4] but in general it is not recommended; the usual recommendation is to use indexed variables ie use p/@Range[4]; this seems relevant; on a different note, perhaps this is helpful, also$\endgroup$
$\begingroup$You could use Table[StringTemplate["p``"][i], {i, 5}] (see this answer) or maybe Table["p" <> IntegerString[i, 10], {i, 1, 5}]. But, as user42582 points out, it is better to consider using indexed variables. For example: Array[p, 5] (but avoid subscripted variable names, as in Array[Subscript[a, #] &, {5}], as (IMO at least) these can cause problems).$\endgroup$
ToExpression[StringJoin["p",ToString[#]]]&/@Range[4]
but in general it is not recommended; the usual recommendation is to use indexed variables ie usep/@Range[4]
; this seems relevant; on a different note, perhaps this is helpful, also $\endgroup$Table[StringTemplate["p``"][i], {i, 5}]
(see this answer) or maybeTable["p" <> IntegerString[i, 10], {i, 1, 5}]
. But, as user42582 points out, it is better to consider using indexed variables. For example:Array[p, 5]
(but avoid subscripted variable names, as inArray[Subscript[a, #] &, {5}]
, as (IMO at least) these can cause problems). $\endgroup$