Permute

C10 - initial

permute (Sifts)
TypeCorrade progressive sift
Siftpermute
Parametersan integer representing the number of rotations
DescriptionThe permute sift will rotate the elements of the list left or right a number of times depending on the provided parameter.
Last ChangesNone

The permute sift will rotate the elements of the list left or right a number of times depending on the provided parameter.

Arguments

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 $i \mapsto i-\|k\|$ for a left rotation and $i \mapsto i+\|k\|$ for a right rotation where $i \in \mathbb{N}$ is the index of an arbitrary item of the array and $\|k\| \in \mathbb{N}$ is the absolute value of the integer.

The permute sift wraps the CSV list around such that when $i \mapsto i-1$ 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 $i \mapsto i+1$, the last element becomes the first element and the first element becomes the second element.

Example

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"
    ]),

Effect on Returned Data

Given the input:

data=1,a,2,c,3,d

then the following transformations will occur:

  • skip, 2 $\leadsto$ 2,c,3,d
  • permute, -2 $\leadsto$ 3,d,2,c

and the expected output will be:

3,d,2,c

secondlife/scripted_agents/corrade/api/sifts/permute.txt ยท Last modified: 2022/11/24 07:46 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.