C10 - initial
permute (Sifts) | |
---|---|
Type | Corrade progressive sift |
Sift | permute |
Parameters | an integer representing the number of rotations |
Description | The permute sift will rotate the elements of the list left or right a number of times depending on the provided parameter. |
Last Changes | None |
The permute
sift will rotate the elements of the list left or right a number of times depending on the provided parameter.
Position | Type | Description | Example |
---|---|---|---|
0 | an integer | the number and direction of rotations | -2 |
You can imagine the CSV list returned by Corrade to the data
parameter as an indexed array of items. Positive integers represent rotations to the right and negative rotations represent rotations to the left. A rotation (or permutation) in terms of the permute
sift means a shift of all elements in the array such that for a left rotation and for a right rotation where is the index of an arbitrary item of the array and is the absolute value of the integer.
The permute
sift wraps the CSV list around such that when the first element will become the last element and the second element will become the first element in the CSV list. Conversely, for a right-rotation , the last element becomes the first element and the first element becomes the second element.
The following sift, when added to a command, will delete the first two items of the CSV list and then rotate the resulting list twice to the left.
"sift", wasListToCSV([ "skip", 2, "permute", "-2" ]),
Given the input:
data=1,a,2,c,3,d
then the following transformations will occur:
2,c,3,d
3,d,2,c
and the expected output will be:
3,d,2,c
For the copyright, license, warranty and privacy terms for the usage of this website please see the license, privacy, copyright and the plagiarism pages.