how to get the ordinal number in list

Roy Smith roy at panix.com
Mon Aug 11 07:55:29 EDT 2014


In article <b3c69a72-5f0c-4e2a-8ef0-91842e12c7d0 at googlegroups.com>,
 Rustom Mody <rustompmody at gmail.com> 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 :-)



More information about the Python-list mailing list