Topic: APLX Help : Help on APL language : APL Primitives : ⌽ Rotate
[ Previous | Next | Contents | Index | APL Home ]

www.microapl.co.uk

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 | APL Home ]