Function: Difference between revisions

Jump to navigation Jump to search
16 bytes added ,  13:08, 24 March 2020
no edit summary
mNo edit summary
No edit summary
Line 1: Line 1:
In [[APL syntax]], a '''function''' applies to [[array]] [[argument]]s to produce an array result (although some APLs allow functions to return other syntactic elements). Unlike many programming languages which use parentheses or brackets for function calls, function application in APL is written simply by writing the function next to its arguments. Functions may be [[primitive function]]s, [[derived function]]s (including [[train]]s), or [[defined function]]s. They can be used as [[operand]]s to [[operator]]s; in early APLs operands were always functions, but nearly all modern APLs allow array operands, for example to the [[Power operator]].
In [[APL syntax]], a '''function''' (or '''verb''') applies to [[array]] [[argument]]s to produce an array result (although some APLs allow functions to return other syntactic elements). Unlike many programming languages which use parentheses or brackets for function calls, function application in APL is written simply by writing the function next to its arguments. Functions may be [[primitive function]]s, [[derived function]]s (including [[train]]s), or [[defined function]]s. They can be used as [[operand]]s to [[operator]]s; in early APLs operands were always functions, but nearly all modern APLs allow array operands, for example to the [[Power operator]].


A key feature distinguishing APL from [[wikipedia:functional programming|functional programming]] languages such as [[wikipedia:Lisp (programming language)|Lisp]] is that APL functions are not first class objects: they cannot be passed directly as arguments to other functions like arrays. Instead, functions might be considered "second class" objects while [[operator]]s are "third class" and [[hyperator]]s, if present, are "fourth class" or more. In a few APLs, most prominently [[A+]], a mechanism is provided to pass functions as arguments, making functions first class if a special function call syntax is used.
A key feature distinguishing APL from [[wikipedia:functional programming|functional programming]] languages such as [[wikipedia:Lisp (programming language)|Lisp]] is that APL functions are not first class objects: they cannot be passed directly as arguments to other functions like arrays. Instead, functions might be considered "second class" objects while [[operator]]s are "third class" and [[hyperator]]s, if present, are "fourth class" or more. In a few APLs, most prominently [[A+]], a mechanism is provided to pass functions as arguments, making functions first class if a special function call syntax is used.

Navigation menu