Commutator

 Z←{L} f⍫g R applies the function g then f then g⍣¯1 and then f⍣¯1 to or between the arguments.
L is an optional array.
R is an array.
f is an arbitrary ambivalent function with an inverse.
g is an arbitrary monadic function with an inverse.

Notation

The symbol chosen for this operator is the Del overstruck with Tilde (), entered from the keyboard as Alt-’K’ or Alt-Shift-'k' (U+236B).

Introduction

The concept of the Commutator operator is taken from mathematical Group Theory from the 1830s.

For example, the algorithm for Partitioned Plus Scan where P is the Boolean partition vector (always with a leading 1), in modern notation looks like this:

```      P←1 0 0 1 0 1 0 0 0
R←1 2 3 4 5 6 7 8 9
+\R-  P\  ¯2-\  P/  +\  ¯1↓0,R
1 3 6 4 9 6 13 21 30
```

An interesting observation on this one-liner is that it contains two interleaved pairs of inverses: P\ and P/ as one and ¯2-\ and +\ as the other. This interleaving of inverses exactly matches the template for the Commutator Operator:

f-1 g-1 f g

where f⍣¯1 ←→ P∘\     g⍣¯1 ←→ ¯2∘(-\)     f ←→ P∘/     g ←→ +\

which can be re-written as

```      +\R- P∘/⍫(+\) ¯1↓0,R
1 3 6 4 9 6 13 21 30
```

```{⍺←⍣0 ⋄ (⍵⍵ ⍺) ⍺⍺⍣¯1 ⍵⍵⍣¯1 (⍵⍵ ⍺) ⍺⍺ ⍵⍵ ⍵}