Multiple assignment between lists in Mathematica 7?

I think the Thread only works on "explicit" lists; the variables need to be expanded before being operated on.

I think the Thread only works on "explicit" lists; the variables need to be expanded before being operated on. After some experimentation, this works for me: a = {a1, a2, a3}; be = {b1, b2, b3}; ThreadSetEvaluate@a, Evaluate@b; {a1, a2, a3} You could also write ThreadEvaluate@a = Evaluate@b; just depends whichever you find more readable.

Thanks. Actually Evaluate@a = Evaluate@b is enough. I didn't know the command 'Evaluate'.

– Explogit Oct 31 '09 at 15:55.

Here's another solution: a = {a1, a2, a3}; be = {b1, b2, b3}; each{x_, y_}, Transpose{a, b}, x = y Which uses my handy each function: SetAttributeseach, HoldAll; (* eachpattern, list, body *) eachpat_, lst_, bod_ := (* converts pattern to body for *) ScanReplace#, pat:>bod&, Evaluate@lst (* each element of list. *) Similarly, you can do this: MapThread(#1 = #2)&, {a, b}.

Well, if they are really called a1, a2, etc, you could do this: Assignx_, y_ := Module{s1, s2, n, sn}, s1 = SymbolNameUnevaluatedx; s2 = SymbolNameUnevaluatedy; Forn = 1, n sn = EvaluateSymbols2 sn SetAttributesAssign, HoldAll And then Clearb1, b2, b3; Cleara1, a2, a3; a = {a1, a2, a3} be = {b1, b2, b3} Assigna, be a Gives the results for a, be and a again as: {a1, a2, a3} {b1, b2, b3} {b1, b2, b3} As expected. In general you can create expressions like these from proper use of SymbolName and Symbol, but be careful with your evaluation. If I had written SymbolNamex (without the Unevaluated) then it would've interpreted that as SymbolName{a1, a2, a3}, which is clearly not desirable.

Not using Evaluate on Symbols1 sn will have Mathematica complain that you're trying to reassign the Symbol function.

Yikes. I think I prefer my solution :) – Will Robertson Oct 31 '09 at 8:45 Yes, yours is infinitely better. (Upvoted) I blame the early morning, and months of working in imperative languages without touching Mathematica :) – Joren Oct 31 '09 at 8:50 Oh, I definitely know that feeling!

– Will Robertson Oct 31 '09 at 9:36.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions