5
$\begingroup$
spA = {}; spB = {}; spC = {};

AppendTo[#, {"Up", "Down"}] & /@ {spA, spB, spC}

doesn't work in Mathematica 11.1.1.

Why? What is an alternative?

$\endgroup$
1
  • 1
    $\begingroup$ just plain Append ? $\endgroup$
    – george2079
    Jun 5 '17 at 17:33
4
$\begingroup$

It's an evaluation leak issue. You could try:

spA={}; spB={}; spC={};

Function[Null,AppendTo[#,{"Up","Down"}],HoldAll] /@ Unevaluated@{spA,spB,spC};
spA
spB
spC

{{"Up", "Down"}}

{{"Up", "Down"}}

{{"Up", "Down"}}

$\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.