Re:SEPA: A Simple, Efficient Permutation Algorithm
by ur-whale on Sunday September 23, 2018 @06:10PM
(#18053565)
You'd better hope that a!=b
[ Parent
| on HN ]
Re:SEPA: A Simple, Efficient Permutation Algorithm
by and-then on Sunday September 23, 2018 @09:31PM
(#18054409)
Edge-case FUD.
Re:SEPA: A Simple, Efficient Permutation Algorithm
by scj on Sunday September 23, 2018 @07:42PM
(#18053987)
Why would a==b be a problem with the XOR swap trick?
function xorSwapTest(min, max) {
for (var i = min; i < max; i++) {
var a = i, b = i;
b ^= a;
a ^= b;
b ^= a;
if (a != i || b != i)
throw Error("Problem with " + i);
}
return true;
}