PermutationDescriptor.rotateRight constructor
Creates a right rotation of length elements by amount.
Implementation
factory PermutationDescriptor.rotateRight(int length, int amount) {
if (amount < 0) {
throw RohdHclException('Permutation rotation amount cannot be negative.');
}
if (length <= 0) {
throw RohdHclException('Permutation rotation length must be positive.');
}
final normalizedAmount = amount % length;
return PermutationDescriptor([
for (var outputIndex = 0; outputIndex < length; outputIndex++)
(outputIndex + normalizedAmount) % length,
]);
}