2
$\begingroup$

So lets say I have

a = Some complicated code that changes
list = {}
AppendTo[list, a]

Obviously it would give me

list={a, a, a, ...}

Due to symbolic nature of mathematica when I change a all of the elements will change.I want to append only the current value of a so that i can add different values in list.

$\endgroup$
1
  • 1
    $\begingroup$ "Due to symbolic nature of mathematica when I change a all of the elements will change." No, they won't, unless the "element" in a changes. Please show us a specific example that can reproduce your problem. $\endgroup$ – xzczd Jul 18 '20 at 2:49
2
$\begingroup$
a := 5 x
list = {}

x = 1

b = a

AppendTo[list, b]
(*{5}*)

x = 2

b = a

AppendTo[list, b]
(*{5, 10}*)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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