Rotate: Difference between revisions

From The K Language Wiki
Content added Content deleted
m (Lowercase title)
m (Lowercase)
Line 2: Line 2:
{{primitive|x!y|in=K3}}
{{primitive|x!y|in=K3}}


'''Rotate'''<ref>https://github.com/kevinlawler/kona/wiki/Rotate_mod</ref> is a verb that rotates an array <code>y</code> by the number of elements given in <code>x</code>.
'''rotate'''<ref>https://github.com/kevinlawler/kona/wiki/Rotate_mod</ref> is a verb that rotates an array <code>y</code> by the number of elements given in <code>x</code>.


Positive <code>x</code> rotates left, and negative <code>x</code> rotates right.
Positive <code>x</code> rotates left, and negative <code>x</code> rotates right.

Revision as of 20:48, 8 July 2022


Rotate
x!y
Supported in K3

rotate[1] is a verb that rotates an array y by the number of elements given in x.

Positive x rotates left, and negative x rotates right.

  2! 1 2 3 4 5 6 7
3 4 5 6 7 1 2
  -2! 1 2 3 4 5 6 7
6 7 1 2 3 4 5
Works in: Kona

References