in reply to Re^6: How do I reverse the order of the first and last word of a string?
in thread How do I reverse the order of the first and last word of a string?

I would never thought about that, I guess I'm a lazy programmer, I used to use a third variable but now I use
($a, $b) = ($b, $a) ;

Anyway, your code could be reduced by one line
b = b + a ; a = b - a ; b = b - a ;
But I guess you already knew that!

LuCa

Replies are listed 'Best First'.
Re^8: How do I reverse the order of the first and last word of a string?
by blazar (Canon) on Mar 11, 2007 at 12:14 UTC
    Anyway, your code could be reduced by one line
    b = b + a ; a = b - a ; b = b - a ;

    Actually, I absolutely can't remember what my "original" code was really like. I "reconstructed" it this morning but didn't put much thought in it: just wanted to stick with with a scheme like that of the XOR trick, with the same operation on all (first three) lines. Of course, since XOR is again both plus and minus in Z_2, then the above code is equivalent to it too.