Skip to main content

⌸ — Key

Monadic operator. Keys: Alt-q =. Hanzi: 组 (組)

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.

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

Fast combinations

BPL computes each of these combinations by an algorithm of its own, in any spelling. Trains says which spellings BPL recognises.

Combination Applies to Benefit
≢⊢ ⌸Y or K (≢⊢)⌸Y any keys counts each group’s major cells without building the groups
K (f/⊢)⌸Y or K (f⌿⊢)⌸Y, with f of + ⌈ ⌊, or × of floats a vector Y of floats, integers or Booleans folds every group in one pass, without a call of the operand for each group
≢⊢ ⌸"banana"                                ⍝ [1 3 2]ₓ
1 1 2(+/⊢)⌸10 20 30                         ⍝ 30 30
(•explain "1 1 2(+/⊢)⌸10 20 30").fast.rule  ⍝ ["group folds"]