Major cell search

From APL Wiki
Jump to navigation Jump to 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 ShapeRankDepthBoundIndex (Indexing) ∙ AxisRavelRavel orderElementScalarVectorMatrixSimple scalarSimple arrayNested arrayCellMajor cellSubarrayEmpty arrayPrototype
Data types Number (Boolean, Complex number) ∙ Character (String) ∙ BoxNamespaceFunction array
Concepts and paradigms Conformability (Scalar extension, Leading axis agreement) ∙ Scalar function (Pervasion) ∙ Identity elementComplex floorArray ordering (Total) ∙ Tacit programming (Function composition, Close composition) ∙ GlyphLeading axis theoryMajor cell searchFirst-class function
Errors LIMIT ERRORRANK ERRORSYNTAX ERRORDOMAIN ERRORLENGTH ERRORINDEX ERRORVALUE ERROREVOLUTION ERROR