Identity element

The identity element for a dyadic function is a value inherent to that function. It is defined as the value which would preserve the other argument of the dyadic function application, possibly only for a well-defined subset of the function's domain.

Left and right identities
Since the identity element preserves the other argument, it can be a left and/or a right identity. For example, Add has the left and right identity element   because   and   for all arrays   in the domain of. However, the identity of Divide, , is only a right identity because while   is true for all   in the domain of  , this isn't so for  , and no alternative identity element value exists which would fulfil the condition.

Reduction over a length-0 axis
If a reduction (using one of,  ,  , or  ) is performed over an axis of length 0, the resulting array is filled with identity elements. For example, the sum of an empty list is, while the columnar sum of a two-column matrix with no rows is  :

Support
Dialects differ in their support for such reductions. All define identity elements for most scalar primitives, and some stop there (e.g. SAX), while others (e.g. Dyalog APL and APL2) define identity elements for various mixed functions.

The identity element value for each function is defined in terms of the prototype  of the array  :

Documentation

 * Dyalog APL


 * APL2