-1
$\begingroup$
Clear[a, b, c];
a = c;    a =. ;    b = a;    b =.;    c = b;    c =.;
Print[a, b]

and the result is

{a b}

but I want the result {b a} by using a Temp help. how is the code suppose to be?

$\endgroup$

closed as unclear what you're asking by Daniel Lichtblau, Henrik Schumacher, MarcoB, Coolwater, m_goldberg Apr 18 '18 at 19:33

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Is this what you need? Print[a, b] // Inactivate // Reverse // Activate $\endgroup$ – Kuba Apr 18 '18 at 8:42
  • $\begingroup$ i dont get it, the expample is i want to Give the value of A to Temp, Then give the Value of B to A, and C to B and the last Temp to C. so the result if i Print[A,B] its will result B,A . And also work if i input values $\endgroup$ – Bagoes Heikhal Apr 18 '18 at 8:56
  • $\begingroup$ I don't think it makes sense unless a/b/c have values. Can you provide a small example? $\endgroup$ – Kuba Apr 18 '18 at 9:02
  • 1
    $\begingroup$ {a, b, c} = {b, c, a};? $\endgroup$ – Kuba Apr 18 '18 at 9:06
  • 1
    $\begingroup$ Unclear what is wanted that would not induce infinite recursion. Maybe something like this (also suggested by @Kuba)? In[277]:= x = 3; y = 5; {x, y} = {y, x}; {x, y} Out[280]= {5, 3} $\endgroup$ – Daniel Lichtblau Apr 18 '18 at 13:56
1
$\begingroup$
Clear[a, b]
a := Defer[b]; b := Defer[a];
Print[a, b]

ba

With values

Clear[a, b, c]
a = 1; b = 2;
c = a; a = b; b = c;
Print[a, b]

21

$\endgroup$
  • $\begingroup$ How to make its work if i input the variable with values $\endgroup$ – Bagoes Heikhal Apr 18 '18 at 8:59
1
$\begingroup$

I don't think the output the OP has in mind is possible within reasonable bounds of normal programming. If you want a to evaluate to b and b to evaluate to a, the evaluation chain will never end.

If you're only interested in the output, use Defer:

a = Defer[b];
b = Defer[a];    
Print[a, b]
$\endgroup$

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