Among the supported mutators, the modulo (remainder) operation only occurs once: a % b can be mutated to a * b, and the assignment expression a %= b to a *= b.
But when dealing with modulo, the most similar operator – the one that’s easiest to confuse – is floor division. That’s why I suggest the addition of the following mutators, using // to mean floor division:
a % b to a // b
a // b to a % b
a %= b to a //= b
a //= b to a %= b
This could be implemented just like the other mutators in Scala and C#.
JavaScript unfortunately does not have a built-in integer-division operation for numbers – only for BigInts. So perhaps in that case, the pattern Math.floor(n / d) can be recognised and mutated to n % d, and vice versa.
Among the supported mutators, the modulo (remainder) operation only occurs once:
a % bcan be mutated toa * b, and the assignment expressiona %= btoa *= b.But when dealing with modulo, the most similar operator – the one that’s easiest to confuse – is floor division. That’s why I suggest the addition of the following mutators, using
//to mean floor division:a % btoa // ba // btoa % ba %= btoa //= ba //= btoa %= bThis could be implemented just like the other mutators in Scala and C#.
JavaScript unfortunately does not have a built-in integer-division operation for numbers – only for
BigInts. So perhaps in that case, the patternMath.floor(n / d)can be recognised and mutated ton % d, and vice versa.