Operator valence

From APL Wiki
Revision as of 15:15, 30 April 2020 by Marshall (talk | contribs) (Operators category)
Jump to navigation Jump to search
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.


APL syntax [edit]
General Comparison with traditional mathematicsPrecedenceTacit programming (Train, Hook, Split composition)
Array Numeric literalStringStrand notationObject literalArray notation (design considerations)
Function ArgumentFunction valenceDerived functionDerived operatorNiladic functionMonadic functionDyadic functionAmbivalent functionDefined function (traditional)DfnFunction train
Operator OperandOperator valenceTradopDopDerived operator
Assignment MultipleIndexedSelectiveModified
Other Function axisBracket indexingBranchStatement separatorQuad nameSystem commandUser commandKeywordDot notationFunction-operator overloadingControl structureComment