Operator: Difference between revisions

Jump to navigation Jump to search
1,417 bytes added ,  16:14, 13 March 2020
no edit summary
(Created page with "In APL syntax, an '''operator''' applies to function or array operands to yield a derived function result. Operators bind with higher precedence than f...")
 
No edit summary
Line 7: Line 7:
* A [[dyadic operator]] takes a left and a right operand.
* A [[dyadic operator]] takes a left and a right operand.
Unlike with [[monadic]] and [[dyadic function]]s, an operator's valence is an intrinsic property and must be known in order to parse an APL expression containing it. Also unlike [[function]]s, there is no such thing as a "niladic operator" taking no operands, because this would be indistinguishable from a [[niladic function]].
Unlike with [[monadic]] and [[dyadic function]]s, an operator's valence is an intrinsic property and must be known in order to parse an APL expression containing it. Also unlike [[function]]s, there is no such thing as a "niladic operator" taking no operands, because this would be indistinguishable from a [[niladic function]].
In [[Iverson notation]] and early APL interpreters, operators were not considered together as a class. Instead, each was thought of as its own piece of syntax. Eventually operators came to be thought of in the modern sense as higher-order functions. As a result, in most modern APLs operators can be applied to any function rather than a limited set ([[A+]] is a relatively recent exception), the programmer can [[defined operator|define]] their own operators, and existing operators (such as [[primitive operator]]s and [[dop]]s) can be [[assignment|assigned]] names. However, some syntactic oddities remain as a result of treating operators as a special syntax: the [[Outer Product]] is written with two symbols when one would work just as well, and some operators share glyphs with operations that seem to be [[function]]s, for example [[Reduce]] and [[Replicate]]. The latter condition has led to the introduction of [[function-operator overloading]] in some APLs.
Newer languages like [[J]] and [[K]] which do not maintain [[backwards compatibility]] with APL usually make the operator syntax more regular. In [[J]], operators (termed "adverbs" for [[monadic operator|monadic]] and "conjunctions" for [[dyadic operator]]s) are considered simply as higher-order functions and there is no concept of a [[derived function]]. An operator can return any array or function, or even another operator.
{{APL syntax}}

Navigation menu