ID:257760
 
//Title: XOR-Based Number Swapping
//Credit to: Wikipedia
//Contributed by: Xx Dark Wizard xX

//This lets you swap 2 different variables without a temp variable
//Also make sure to only use this on things greater then 0 and less than 65535

#define XorSwap(a,b) a^=b;b^=a;a^=b

mob
verb
test(a as num, b as num)
src<<"Before swap a: [a], b: [b]"
XorSwap(a,b)
src<<"After swap a: [a], b: [b]"
Credit to Wikipedia? Are you sure that's wise? Wikipedia is protected under the GNU Free Documentation Licence, which means that your snippet would also be covered by that licence. You can freely claim credit to that snippet because it's not derivative of Wikipedia, you know. ;-)