1
$\begingroup$

I am generating an Array with symbolic coefficients:

coefficients = Array[c, 3]
> {c[1], c[2], c[3]}

I would like to assign a value to each of these generated coefficients, such that in one go, c[1] = 2, c[2] = 4, c[3] = 6. Now the following statement:

 coefficients = {2,4,6};

does not do that: it merely changes the array's entries, but doesn't actually assign anything to c[1] ... c[3].

I've been trying to play with Hold and Unevaluated functions to achieve this, but to no avail. Is there a way to do this?

$\endgroup$
4
  • $\begingroup$ Can you find the answer there? 72857 $\endgroup$
    – Kuba
    Feb 6, 2015 at 11:05
  • $\begingroup$ Thank you, that indeed had the answer: Unevaluated[coefficients = {1, 2, 3}] /. OwnValues[coefficients] Should I delete this question as it's a duplicate? $\endgroup$
    – Jelle
    Feb 6, 2015 at 11:09
  • 1
    $\begingroup$ You don't have to. It will stay here as a road sign for future visitors. This is FAQ but it is not easy to find since keywords are not obvious. So the more duplicates the better in this case. $\endgroup$
    – Kuba
    Feb 6, 2015 at 11:10
  • $\begingroup$ For generalized handling of list assignments please see (10322) $\endgroup$
    – Mr.Wizard
    Feb 6, 2015 at 15:48

0

Browse other questions tagged or ask your own question.