Operator valence

From APL Wiki
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]
Overview Comparison with traditional mathematicsPrecedence
Array Numeric literalStringStrand notationObject literalArray notation
Function ArgumentFunction valenceDerived functionFunction trainMonadic functionDyadic functionAmbivalent function
Operator OperandOperator valenceDerived functionDerived operator
Assignment MultipleIndexedSelectiveModified
User definition TradfnDfnTacit
Other Function axisBranchingSystem commandUser commandKeywordDot notation