Empty array: Difference between revisions

Jump to navigation Jump to search
889 bytes added ,  11:24, 13 November 2019
Miraheze>Adám Brudzewsky
Miraheze>Adám Brudzewsky
Line 43: Line 43:
{{Works in|[[Dyalog APL]]}}
{{Works in|[[Dyalog APL]]}}


== Reduction over a length-0 axis ==
If a [[reduce|reduction]] (using one of <source lang=apl inline>/</source>, <source lang=apl inline>⌿</source>, <source lang=apl inline>\</source>, or <source lang=apl inline>⍀</source>)is performed over an axis of length 0, the resulting array is filled with [[identity element]]s. For example, the sum of an empty list is 0 because the identity element for [[addition]] is 0:
<source lang=apl>
      +/0⍴0
0
</source>
The identity element for a specific reduction always depends on the operand, and may depend on the argument array prototype. Dialects differ in their support for such reductions. All define identity elements for most [[scalar functions#Standard scalar functions|scalar primitives]], and some stop there (e.g. [[SAX]]), while others (e.g. [[Dyalog APL]] and [[APL2]]) define identity elements for various [[mixed functions]].
{{APL programming language}}
{{APL programming language}}

Navigation menu