Total array ordering
- TAO links here. For the chat room, see The APL Orchard.
In APL, a total array ordering, or TAO, is an ordering on all arrays which is used primarily by Grade and Interval Index, but optionally also by the comparison functions. Traditionally ordering is defined only for simple arrays of the same shape and type, so TAO refers to the extension to nested or boxed arrays of arbitrary rank, shape, and type.
J has had such an ordering since 1996 (release 3.01). Dyalog APL added a total array ordering with version 17.0. Both of these are based on a lexicographic ordering. GNU APL and NARS2000 also implement total ordering, but based on shortlex ordering instead, comparing first rank, then shape, then type, and finally value.
The name total array ordering is taken partly from the mathematical concept of a total order, which must order any two elements, with elements ordering equally only if they are identical. This concept is transferred to APL by specifying that arrays should only order equally if they match.
Exceptions from the ordering
Some dialects do not implement a true total order because they support arrays without defining an order for them.
Dyalog APL excludes simple scalars other than nulls, numbers or characters (namely namespaces, objects, and object representations), because ordering those was considered "contentious but of little incremental benefit." Roger Hui has argued that these scalars are not truly arrays, and are not in the scope of a total array ordering. However, the dfns workspace includes an APL model which is truly total, though it differs from the native implementation in ordering characters before numbers instead of the opposite.
NARS2000's excludes complex numbers (including quaternions and octonions) from the ordering. It should be noted that these numbers do not belong to any ordered field: any ordering that remains the same after adding a constant could not be compatible with multiplication in the sense that the product of any two numbers greater than zero is greater than zero.
- ↑ Hui, R.. The TAO of J.
- ↑ Hui, R. and M. Kromberg. APL since 1978. ACM HOPL IV. 2020-06.
- ↑ 3.0 3.1 Brudzewsky, A., J. Foad, and R. Hui. TAO Axioms. 2018-02-02.
- ↑ Dfns workspace.
le― Total array ordering (TAO) comparison.
|APL features |
|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 ∙ Total array ordering ∙ Tacit programming (Function composition, Close composition) ∙ Glyph|
|Errors||LIMIT ERROR ∙ RANK ERROR ∙ SYNTAX ERROR ∙ DOMAIN ERROR ∙ LENGTH ERROR ∙ INDEX ERROR ∙ VALUE ERROR|