1
$\begingroup$

Using Mathematica, I was trying to get {#1,#2,#3,#4,#5}, using Table[#n, {n, 1, 5}] Instead I only got {#n, #n, #n, #n, #n} How can I get {#1,#2,#3,#4,#5},

$\endgroup$
3
  • 1
    $\begingroup$ Table[Slot[i], {i, 5}] $\endgroup$ Commented Apr 13, 2023 at 4:28
  • 2
    $\begingroup$ Or instead of Table, use Slot /@ Range[5] $\endgroup$ Commented Apr 13, 2023 at 4:48
  • 2
    $\begingroup$ You have been a member for several years now. I note that you don't format your posts correctly and haven't been accepting any answers for a while now. Your participation is important. $\endgroup$ Commented Apr 13, 2023 at 8:43

2 Answers 2

4
$\begingroup$

Shortest would be to use Array:

Array[Slot, 5]

(*    {#1, #2, #3, #4, #5}    *)
$\endgroup$
0
$\begingroup$

Thanks for the solns. In the meantime I also came up with: Table[ToExpression["#" <> ToString[n]], {n, 5}] , but the other solutions are more elegant.

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.