On 11/08/2014 13:30, Tim Chase wrote:
On 2014-08-11 07:55, Roy Smith wrote:
A C programmer asked to swap variables x and y, typically writes
something like

t = x; x = y; y = t;

Fine, since C cant do better.

Sure C can do better.

x = x ^ y
y = y ^ x
x = x ^ y

Any self-respecting C hacker would write it this way :-)

Pish, such redundancy...everyone knows a C programmer would write
that as

  x ^= y
  y ^= x
  x ^= y

:-)

-tkc


That says the LHS is assigned the RHS rotated by some angle, which I'll assume to be 90 degrees clockwise, yes? Well I don't suppose it really matters for x as it'll still be x when it gets assigned to y, but what would you call the shift on y that gets assigned to x?

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to