Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • C
a^=b;
b^=a;
a^=b;

Only works for integer values (or casted pointers)
b = a + b
a = b - a
b = b - a

Simple math, should probably work for any number
procedure swap(a, b: in out Integer)
is
    temp : Integer;
begin
    temp := a;
    a := b;
    b := temp;
end swap;

New implementation...
programming-idioms.org