Function array: Difference between revisions

Jump to navigation Jump to search
14 bytes added ,  10:40, 22 August 2022
m
no edit summary
m (Features navbox instead of syntax)
mNo edit summary
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 field of an array of [[namespace]]s that all contain that field with a function value. <source lang=apl inline>fnarray</source> in the [[dfns workspace]] wraps this functionality in an operator.<ref>[[Dfns workspace]]. [https://dfns.dyalog.com/n_fnarray.htm <source lang=apl inline>fnarray</source>] ― Array of functions.</ref>
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. <source lang=apl inline>fnarray</source> in the [[dfns workspace]] wraps this functionality in an operator.<ref>[[Dfns workspace]]. [https://dfns.dyalog.com/n_fnarray.htm <source lang=apl inline>fnarray</source>] ― 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 functions, lists may be applied to arguments, and apply each element independently, so that a list of functions also behaves like a function array.
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 functions, lists may be applied to arguments, and apply each element independently, so that a list of functions also behaves like a function array.

Navigation menu