Monadic operator: Difference between revisions

Jump to navigation Jump to search
281 bytes added ,  15:14, 30 April 2020
m
Operators category
mNo edit summary
m (Operators category)
(3 intermediate revisions by one other user not shown)
Line 4: Line 4:


When called monadically, a monadic operator with an array operand has the same syntax as a [[dyadic function]]: in each case, there is one array to the left and one to the right of the operator or function. The difference is that while the value on the right is always an [[argument]], the one on the left is an [[operand]] to the operator but an argument to the function. This means that the operator can be applied in two steps: in most modern dialects the operand and its operator can be separated, for example changing the [[Constant operator]] call <source lang=apl inline>A ⍨ B</source> to <source lang=apl inline>toA←A ⍨ ⋄ toA B</source>, but few allow the array-function combination that would be required to change the equivalent [[Identity]] call <source lang=apl inline>A ⊢ B</source> to <source lang=apl inline>toA←A ⊢ ⋄ toA B</source>. In some dialects this ambiguity is used to allow [[function-operator overloading]], where a value can be either a monadic operator or a dyadic function depending on context.
When called monadically, a monadic operator with an array operand has the same syntax as a [[dyadic function]]: in each case, there is one array to the left and one to the right of the operator or function. The difference is that while the value on the right is always an [[argument]], the one on the left is an [[operand]] to the operator but an argument to the function. This means that the operator can be applied in two steps: in most modern dialects the operand and its operator can be separated, for example changing the [[Constant operator]] call <source lang=apl inline>A ⍨ B</source> to <source lang=apl inline>toA←A ⍨ ⋄ toA B</source>, but few allow the array-function combination that would be required to change the equivalent [[Identity]] call <source lang=apl inline>A ⊢ B</source> to <source lang=apl inline>toA←A ⊢ ⋄ toA B</source>. In some dialects this ambiguity is used to allow [[function-operator overloading]], where a value can be either a monadic operator or a dyadic function depending on context.
{{APL syntax}}
== Operand currying ==
Some dialects allow [[wikipedia:currying|currying]] one operand to a dyadic operator, creating a monadic operator:
<source lang=apl>
      Thrice←⍣3
      1 +Thrice 4
7
</source>
Some dialects only allow currying the right operand.
{{APL syntax}}[[Category:Operators]]

Navigation menu