Function: Difference between revisions
Jump to navigation
Jump to search
m (Functions category) |
(→Function definition: Simplify; will move some things to Function styles) |
||
Line 21: | Line 21: | ||
{{main|Function styles}} | {{main|Function styles}} | ||
Every APL comes with [[primitive function]]s, and almost always [[system function]]s, which are defined by the language. [[ | Every APL comes with [[primitive function]]s, and almost always [[system function]]s, which are defined by the language. In order to create other functions, there are three general methods. Every APL supports at least one of these but there is no universally supported method. | ||
* [[Tacit programming]] treats functions as values to be manipulated directly: [[derived function]]s can be created by applying [[operator]]s to [[operand]]s, and [[train]]s are functions formed from multiple functions. | |||
* [[Anonymous function]]s are defined by a series of expressions that make reference to function arguments ([[dfn]]s use the fixed names <source lang=apl inline>⍺</source> and <source lang=apl inline>⍵</source>). When created they have no name, but they can be [[Assignment|assigned]] one. | |||
* [[Defined function]]s have a function header with syntax that includes the function's name and reflects how it will be used. This is the only way to create [[niladic function]]s. | |||
More recent APLs tend to use the earlier, syntactically simpler, methods on the list above, while older APLs use syntactically more complex ones: in particular, only [[defined function]]s were used in almost all APLs until the 1990s. Because they create functions as values with no names, the first two types require function assignment to create named functions (usually considered a requirement to build complex programs). Function assignment became more common in the 1980s, and, due to the popularity of anonymous functions, is present in all new APLs. | |||
{{APL syntax}}[[Category:Functions| ]] | {{APL syntax}}[[Category:Functions| ]] |