Derived function: Difference between revisions
m (1 revision imported) |
m (Categories) |
||
Line 21: | Line 21: | ||
In APL a [[user-defined operator]] such as a [[tradop]] or [[dop]] creates a derived function from its arguments without executing any of the user's code. In [[J]], the user's code is evaluated and must return a value, which could but doesn't have to be a derived function. | In APL a [[user-defined operator]] such as a [[tradop]] or [[dop]] creates a derived function from its arguments without executing any of the user's code. In [[J]], the user's code is evaluated and must return a value, which could but doesn't have to be a derived function. | ||
{{APL syntax}} | {{APL syntax}}[[Category:Kinds of functions]][[Category:Defining functions]] |
Revision as of 14:43, 30 April 2020
A derived function is the result of applying an operator to its operands. Since it is a function, it can then be applied to argument arrays, resulting in other arrays.
Consider for example applying a Windowed Reduction to an array:
3 ⌈/ 2 9 0 ¯1 0 2 5 9 9 0 2 5
In this statement the Reduce operator (/
) is applied to the Minimum function (⌈
) resulting in the derived function ⌈/
. In most modern APLs this function can be manipulated like any other function, for example to assign it to a name:
f ← ⌈/ 3 f 2 9 0 ¯1 0 2 5 9 9 0 2 5
Here the value of f
is a derived function. Many APLs display a derived function by placing its operands next to the operator, as it is written:
f ⌈/
In APL a user-defined operator such as a tradop or dop creates a derived function from its arguments without executing any of the user's code. In J, the user's code is evaluated and must return a value, which could but doesn't have to be a derived function.