Function array

From APL Wiki
Revision as of 00:19, 20 August 2022 by Marshall (talk | contribs) (Created page with "A '''function array''', or '''fnarray''', is a value that is conceptually an array of functions. It can be applied to arguments, which applies each function indepe...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

A function array, or fnarray, is a value that is conceptually an array of functions. It can be applied to arguments, which applies each function independently and gives an array of results. Several languages that don't ordinarily support placing a function in an array have function arrays as a special construct: Dyalog APL, dzaima/APL, and Nial, which uses the name "atlas".

In dzaima/APL and Nial function arrays are constructed by the vector form of array notation, allowing only rank-1 function arrays. In Dyalog APL they can be produced by taking a field of an array of namespaces that all contain that field with a function value. fnarray in the dfns workspace wraps this functionality in an operator.[1]

The FP language features a "function composition" construction that applies like a function array. In the I language, which has first-class functions, lists may be applied to arguments, and apply each element independently, so that a list of functions also behaves like a function array.

References

  1. Dfns workspace. fnarray ― Array of functions.
APL syntax [edit]
General Comparison with traditional mathematicsPrecedenceTacit programming (Train, Hook, Split composition)
Array Numeric literalStringStrand notationObject literalArray notation (design considerations)
Function ArgumentFunction valenceDerived functionDerived operatorNiladic functionMonadic functionDyadic functionAmbivalent functionDefined function (traditional)DfnFunction train
Operator OperandOperator valenceTradopDopDerived operator
Assignment MultipleIndexedSelectiveModified
Other Function axisBracket indexingBranchStatement separatorQuad nameSystem commandUser commandKeywordDot notationFunction-operator overloadingControl structureComment