# Major cell search

The dyadic functions Index Of (`⍳`

), Interval Index (`⍸`

), and possibly Member Of (`∊`

) can be extended to search argument cells rather than elements, in accordance with the leading axis model. In this model, the "principal argument" (the one that is searched through) is considered as a list of its major cells, and the "non-principal argument" is then split into cells of this rank, which are processed separately: the result for each one depends on which major cells of the principal argument it matches. Because Member Of is defined (since APL\360) to ignore the shape of its right argument and treat it as an unordered collection of elements, it cannot be consistently extended in this way. However, some non-APL languages and the A+ dialect, which breaks backwards compatibility, use this extension.

## History

Major cell searching is supported for all relevant primitives in A+ and J. Some support was added to Dyalog APL under the direction of J implementer Roger Hui in 2014. The more recent array languages BQN and Uiua also define search functions to work on major cells.

Index Of searching major cells was added to Dyalog APL 14.0 in 2014, and Interval Index also featured the extension when it was included in Dyalog APL 16.0. Several other APL dialects have extended Index Of in ways that are incompatible with major cell searching: in SHARP APL it has function rank `1 0`

(while major cell searching would imply a function rank that depends on the rank of the left argument), and in GNU APL and NARS2000 elements are searched to give a multi-dimensional index. NARS2000 defines dyadic `⍸`

, called Array Lookup, to provide Index Of on cells.

Support for major cell searching is compared across languages in the table below.

Language | Index Of | Member Of | Interval Index | Other |
---|---|---|---|---|

Dyalog APL | 2014 | Incompatible | Yes | |

NARS2000 | With `⍸` |
Incompatible | N/A | |

A+ | Yes | Yes | Yes | |

J | Yes | Yes | Yes | Index-of-last |

BQN | Yes | Yes | Yes | Progressive Index of |

Uiua | Yes | Yes | N/A |

## External links

APL features [edit]
| |
---|---|

Built-ins | Primitives (functions, operators) ∙ Quad name |

Array model | Shape ∙ Rank ∙ Depth ∙ Bound ∙ Index (Indexing) ∙ Axis ∙ Ravel ∙ Ravel order ∙ Element ∙ Scalar ∙ Vector ∙ Matrix ∙ Simple scalar ∙ Simple array ∙ Nested array ∙ Cell ∙ Major cell ∙ Subarray ∙ Empty array ∙ Prototype |

Data types | Number (Boolean, Complex number) ∙ Character (String) ∙ Box ∙ Namespace ∙ Function array |

Concepts and paradigms | Conformability (Scalar extension, Leading axis agreement) ∙ Scalar function (Pervasion) ∙ Identity element ∙ Complex floor ∙ Array ordering (Total) ∙ Tacit programming (Function composition, Close composition) ∙ Glyph ∙ Leading axis theory ∙ Major cell search |

Errors | LIMIT ERROR ∙ RANK ERROR ∙ SYNTAX ERROR ∙ DOMAIN ERROR ∙ LENGTH ERROR ∙ INDEX ERROR ∙ VALUE ERROR ∙ EVOLUTION ERROR |