⍸ — Where / Interval index

Function. Keys: Alt-Minus i. Ranks: ∞ monadic, ∞ ∞ dyadic

⍸Y lists exact positions, repeated according to their nonnegative integer counts. Higher-rank arguments give 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. X must be sorted. Unsorted boundaries give 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]ₓ

Query cells and batch axes follow Index Of.

Inverse

⍸⁻¹Y counts how often each position appears in Y.

⍸⁻¹0 2 2   ⍝ [1 0 2]ₓ