Operator valence: Difference between revisions
m (2 revisions imported: Migrate from miraheze) |
m (Text replacement - "</source>" to "</syntaxhighlight>") Tags: Mobile edit Mobile web edit |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 3: | Line 3: | ||
In [[APL syntax]], an [[operator]]'s '''valence''' is the number of [[operand]]s it takes. The valence of an operator is an intrinsic property and must be known in order to parse an APL sentence containing it. Operators may take either one operand, in which case they are called [[Monadic operator|monadic]], or two, in which case they are called [[Dyadic operator|dyadic]]. The valence of an operator is distinct from the [[valence]] of the [[derived function]] produced by after it is applied to its operands: the operator's valence counts operands while the derived function's valence counts [[argument]]s. Unlike with functions, there is no possibility for a [[niladic]] or [[ambivalent]] operator. | In [[APL syntax]], an [[operator]]'s '''valence''' is the number of [[operand]]s it takes. The valence of an operator is an intrinsic property and must be known in order to parse an APL sentence containing it. Operators may take either one operand, in which case they are called [[Monadic operator|monadic]], or two, in which case they are called [[Dyadic operator|dyadic]]. The valence of an operator is distinct from the [[valence]] of the [[derived function]] produced by after it is applied to its operands: the operator's valence counts operands while the derived function's valence counts [[argument]]s. Unlike with functions, there is no possibility for a [[niladic]] or [[ambivalent]] operator. | ||
One special case is that of the [[Inner Product]] and [[Outer Product]] operators. The Inner Product is a dyadic operator < | One special case is that of the [[Inner Product]] and [[Outer Product]] operators. The Inner Product is a dyadic operator <syntaxhighlight lang=apl inline>f.g</syntaxhighlight>, and the Outer Product is written <syntaxhighlight lang=apl inline>∘.g</syntaxhighlight>. Various APLs interpret the latter syntax in different ways. In [[Iverson notation]] and [[APL\360]] an outer product was described as a kind of inner product with an omitted left operand (making the Inner Product ambivalent), but later APLs such as [[Dyalog APL]] typically refer to Outer Product as a separate, monadic operator with a special syntax. [[SHARP APL]] defines <syntaxhighlight lang=apl inline>∘</syntaxhighlight> to be an array ([[Nil]]), so that Inner Product is a purely dyadic operator and the Outer Product is a special case with an array left operand. | ||
{{APL syntax}} | {{APL syntax}}[[Category:Operators]] |
Latest revision as of 22:16, 10 September 2022
- This page is about the number of operands of an operator. For the number of arguments of a function, see function valence.
In APL syntax, an operator's valence is the number of operands it takes. The valence of an operator is an intrinsic property and must be known in order to parse an APL sentence containing it. Operators may take either one operand, in which case they are called monadic, or two, in which case they are called dyadic. The valence of an operator is distinct from the valence of the derived function produced by after it is applied to its operands: the operator's valence counts operands while the derived function's valence counts arguments. Unlike with functions, there is no possibility for a niladic or ambivalent operator.
One special case is that of the Inner Product and Outer Product operators. The Inner Product is a dyadic operator f.g
, and the Outer Product is written ∘.g
. Various APLs interpret the latter syntax in different ways. In Iverson notation and APL\360 an outer product was described as a kind of inner product with an omitted left operand (making the Inner Product ambivalent), but later APLs such as Dyalog APL typically refer to Outer Product as a separate, monadic operator with a special syntax. SHARP APL defines ∘
to be an array (Nil), so that Inner Product is a purely dyadic operator and the Outer Product is a special case with an array left operand.