Search functions

0 1 2 3 4 5 6 7 's' 'e' 'a' 'r' 'c' 'h' 'e' 's' 'e' 's' 's' 'a' 'y' 's' 1 0 0 2 8 0 1 0 7 2 8 8 1 1 1 1 0 1 in for

The three search functions are Index of (), Progressive Index of (), and Member of (). These are dyadic functions that search one argument ("searched-in") for major cells matching cells from the other ("searched-for"). For example, Index of returns, for each cell in 𝕩, the index of the first cell in 𝕨 that matches it.

Name for in Return
Index of 𝕩 𝕨 Index of first match
Progressive Index of 𝕩 𝕨 Index of first unused match
Member of 𝕨 𝕩 1 if found, 0 if not
⍋⍒ Bins 𝕩 𝕨 Predecessor index

The searched-for argument is 𝕩 in Index-of functions (⊐⊒) and 𝕨 in Member of (). Bins Up and Down (⍋⍒) are ordering functions but follow the same pattern as Index-of. It's split into cells, but not necessarily major cells: instead, the cells used match the rank of a major cell of the other (searched-in) argument. In the most common case, when the searched-in argument is a list, 0-cells are used for the search (we might also say elements, as it gives the same result).

The result is always an array containing one number for each searched-for cell. For Index of and Member of, every result is computed independently; for Progressive Index of the result for a cell can depend on earlier cells, in index order.