Skip to main content

⌽ — Reverse / Rotate

Function. Keys: Alt-2. Hanzi: 转 (轉). Ranks: 1 monadic, 0 1 dyadic

⌽Y reverses the last axis. Axis selects another: ⌽₀ reverses the first axis, and ⌽₋₁ the last. ⌽₀ replaces Dyalog’s ⊖.

⌽1 2 3             ⍝ 3 2 1
⌽₀2 2ρι4ₓ           ⍝ [2 3◇0 1]ₓ

N⌽Y rotates left by N places; negative N rotates right. Counts are whole, taken modulo the axis length.

1⌽"abcd"           ⍝ "bcda"
¯1⌽"abcd"          ⍝ "dabc"

A count array supplies counts for the unrotated axes: one count per column when rotating a matrix’s first axis.

1⌽₀3 2ρι6ₓ          ⍝ [2 3◇4 5◇0 1]ₓ
0 1 2⌽₀[1 2 3◇4 5 6◇7 8 9]   ⍝ [1 5 9◇4 8 3◇7 2 6]

Inverse

⌽⁻Y is ⌽Y. X⌽⁻Y rotates Y back by X.

1⌽⁻2 3 1   ⍝ 1 2 3