Function array: Difference between revisions
m (Text replacement - "<source" to "<syntaxhighlight") Tags: Mobile edit Mobile web edit |
m (Text replacement - "first-class function" to "first-class function") |
||
(2 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
A '''function array''', or '''fnarray''', is a value that is conceptually an [[array]] of [[function]]s. It can be applied to [[argument]]s, 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". | A '''function array''', or '''fnarray''', is a value that is conceptually an [[array]] of [[function]]s. It can be applied to [[argument]]s, 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 member of an array of [[namespace]]s that all contain that member, each with its own function value. <syntaxhighlight lang=apl inline>fnarray</ | 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 member of an array of [[namespace]]s that all contain that member, each with its own function value. <syntaxhighlight lang=apl inline>fnarray</syntaxhighlight> in the [[dfns workspace]] wraps this functionality in an operator.<ref>[[Dfns workspace]]. [https://dfns.dyalog.com/n_fnarray.htm <syntaxhighlight lang=apl inline>fnarray</syntaxhighlight>] ― Array of functions.</ref> | ||
The [[wikipedia:FP (programming language)|FP]] language features a "function composition" construction that applies like a function array. In the [[I]] language, which has first-class | The [[wikipedia:FP (programming language)|FP]] language features a "function composition" construction that applies like a function array. In the [[I]] language, which has [[first-class function]]s, lists may be applied to arguments, and apply each element independently, so that a list of functions also behaves like a function array. | ||
== External links == | |||
* [https://dfns.dyalog.com/n_Function_arrays.htm Function arrays] introduction text in [[Dfns workspace]] | |||
== References == | == References == | ||
<references/> | <references/> | ||
{{APL features}}[[Category:Kinds of array]][[Category:Functions]][[Category:APL syntax]] | {{APL features}}[[Category:Kinds of array]][[Category:Functions]][[Category:APL syntax]] |
Latest revision as of 02:09, 6 September 2024
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 member of an array of namespaces that all contain that member, each with its own 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.
External links
- Function arrays introduction text in Dfns workspace
References
- ↑ Dfns workspace.
fnarray
― Array of functions.
APL features [edit] | |
---|---|
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 ∙ Array ordering (Total) ∙ Tacit programming (Function composition, Close composition) ∙ Glyph ∙ Leading axis theory ∙ Major cell search ∙ First-class function |
Errors | LIMIT ERROR ∙ RANK ERROR ∙ SYNTAX ERROR ∙ DOMAIN ERROR ∙ LENGTH ERROR ∙ INDEX ERROR ∙ VALUE ERROR ∙ EVOLUTION ERROR |