## ² Rotate

The numbers or letters in the right-hand argument are shifted by the number of places specified in the left-hand argument. The shift is to the left if the left- hand argument is a positive number and to the right if it's a negative number.

                 1 ² 1 2 3 4 5 6         (Each number moves one place to
           2 3 4 5 6 1                    the left. This displaces the first
                                          number to the end of the line)
                 3 ² 'ABCDEFGH'          (Each letter moves left 3 places.
           DEFGHABC                       This displaces the first 3 letters
                                          to the end of the line)
                 TABLE
           1 2 3 4 5
           6 7 8 9 0
                 3 ²TABLE                (The numbers in each row are moved
           4 5 1 2 3                      3 places to the left. Equivalent to
           9 0 6 7 8                      3²[2]TABLE)
                 ¯2 ²'ABCDEFGH'          (The negative number means a shift
           GHABCDEF                       to the right. All letters are
                                          moved 2 places right)

Similar axis considerations apply to rotate. By default ² applies to the last dimension (as in the example above. First axis rotate, ´, applies by default to the first dimension, but otherwise behaves similarly.

Reverse and rotate can be used for selective specification.

Topic: APLX Help : Help on APL language : APL Primitives : ² Rotate

[ Previous | Next | Contents | Index ]