⌸ — Key

Monadic operator. Keys: Alt-q =

K f⌸Y groups major cells of Y by corresponding keys in K. Calls key f group; groups appear in first-occurrence order.

1 1 2{+/⍵}⌸10 20 30 ⍝ 30 30

f⌸Y uses Y as keys and their positions as values. ≢⊢ ⌸Y counts the items with each key, without building the groups.

≢⊢ ⌸"banana"      ⍝ [1 3 2]ₓ

Keys match with tolerance, as in ≠. Results assemble with fill. Empty input calls f once for its prototype.