1
$\begingroup$

This question already has an answer here:

I got this example in Mathematica references.

v = ToExpression["a" <> ToString[#]] & /@ Range[1,44]

Could someone explain to me the function of the term #? There is another way to get the same result?

And how could I relate v list with another list of 44 lists in it one by one?

lists={{3},{54},...,{46}}

The result would be something like:

a1=3
a2=54
...
a44=46
$\endgroup$

marked as duplicate by MarcoB, m_goldberg, user9660, Kuba, Mr.Wizard list-manipulation Jun 21 '16 at 12:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ Funtion and Slot. $\endgroup$ – Wjx Jun 21 '16 at 1:07
  • $\begingroup$ represents the first argument supplied to a pure function $\endgroup$ – Young Jun 21 '16 at 1:21
  • 1
    $\begingroup$ Things are not so easy when a1, a2... have OwnValues, why not use a[1]? $\endgroup$ – happy fish Jun 21 '16 at 2:22
  • $\begingroup$ For #, search this answer. $\endgroup$ – Michael E2 Jun 21 '16 at 2:24
  • $\begingroup$ Also related: (94294) $\endgroup$ – Michael E2 Jun 21 '16 at 2:26
1
$\begingroup$

Does it help?

a = RandomInteger[9, 44]
(Evaluate[Symbol["a" <> ToString[#]]] = a[[#]]) & /@ Range[44]

{a[[3]], a3}
{a[[11]], a11}

{0, 9, 7, 5, 9, 6, 6, 6, 1, 4, 4, 9, 3, 6, 1, 8, 2, 9, 8, 6, 1, 1, 1, 4, 7, 9, 6, 9, 0, 5, 7, 5, 8, 2, 4, 1, 1, 4, 3, 0, 4, 7, 6, 0}

{7, 7}

{4, 4}

$\endgroup$
  • 1
    $\begingroup$ I don't get it. Is it not working? Can you put a small example of your input and output. $\endgroup$ – Sumit Jun 22 '16 at 8:16
  • $\begingroup$ Sorry, my bad. Check the modified answer. $\endgroup$ – Sumit Jun 22 '16 at 10:06

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