Fri Jun 11 1999 10:34:
It is Fun With Perl... yeah!
$a^=$b^=$a^=$b
I thought it was impossible to swap two variables without using
a third variable, but there it is. I forgot who posted this to the
Fun With Perl list, but I am eternally grateful to them.
Fri Jun 11 1999 10:37:
You could make the case that that implicitly uses a third storage
space to store the results of the xors before it is put into one of
the variables, but even if that does happen, you could design a computer that didn't do that.
I feel like a new xor!
 | Unless otherwise noted, all content licensed by Leonard Richardson under a Creative Commons License. |