⍸ — Where / Interval index
Function. Keys: Alt-Minus i. Hanzi: 处/间 (處/間). Ranks: ∞ monadic, ∞ ∞ dyadic
⍸Y lists exact positions, each repeated by its nonnegative whole count. Higher-rank Y: coordinate vectors.
⍸0 2 0 1 ⍝ [1 1 3]ₓ
For each item of Y, X⍸Y counts the boundaries in X less than or equal to that item, by binary search. Unsorted X gives meaningless counts, not an error. It uses structural ordering, without tolerance.
10 20 30⍸5 10 25 40 ⍝ [0 1 2 3]ₓ
1 3⍸2 ⍝ 1ₓ
1 3⍸⊂2 ⍝ 1ₓ
1 3⍸,2 ⍝ [1]ₓ
Like Index Of, an atom on the left acts as a one-item vector, and a scalar raises RANK. Queries and the result's shape follow the same rules.
Inverse
⍸⁻Y counts how often each position appears in Y.
⍸⁻0 2 2 ⍝ [1 0 2]ₓ