Fill element

From APL Wiki
Revision as of 13:29, 4 November 2019 by Miraheze>Marshall
Jump to navigation Jump to search

A fill element is an element used for the result of a function when no element from the argument or another relevant array is used. The fill element is usually that array's prototype. J allows the fill to be specified using the fit conjunction !., an analogue of Variant.

Fills are one way to convert an empty array into a non-empty array. Reduction along an empty axis also produces such a transition, but in this case an identity element for the reducing function is used instead of a fill.

Uses

The following functions and operators may use fill elements in their results.

Glyph Monad Dyad
Reshape
Mix (or ) Take
/ and Replicate
\ and Expand
Rank operator
Key
Stencil

All functions except Mix derive fill elements from the argument's prototype. In Mix, each element of the argument is extended with fills from its own prototype.

Each operator in the table uses fills to force the results from its left operand to have a common shape—in one nested interpretation, they call Mix on an array with those results as elements. The fills for each result are taken from that result's prototype.

In languages with function rank, fills are similarly used to force result cells of a function with rank to have a uniform shape. This means that fills may be used by any primitive function which can produce differently-shaped result cells in a single application. A notable example is Unbox, which behaves like the nested Mix because of this feature of function rank.

External links

Documentation