Scalar function

From APL Wiki
Revision as of 09:06, 29 October 2019 by Miraheze>Adám Brudzewsky (Text replacement - "<code>" to "<source lang=apl inline>")
Jump to navigation Jump to search

A scalar function is one of a class of primitive functions that apply to arguments one element at a time. Dyadic scalar functions pair elements of their arguments based on conformability rules, and thus are subject to scalar extension. In nested array languages scalar functions recursively descend into nested arrays until they can be applied to simple scalars; in flat array languages they usually do not apply inside boxes.

Only a particular valence of a function is labelled "scalar". The scalar monad Not usually shares the glyph <source lang=apl inline>~ with non-scalar dyad Without, and similarly scalar Roll and non-scalar Deal are both written <source lang=apl inline>?.

Standard scalar functions

Most APLs use a set of scalar functions that was worked out fairly early in APL's development. These are listed in this section.

Monadic functions

<source lang=apl inline>+ Conjugate
<source lang=apl inline>- Negate
<source lang=apl inline>× Signum or Direction
<source lang=apl inline>÷ Reciprocal
<source lang=apl inline>⌊ Floor
<source lang=apl inline>⌈ Ceiling
<source lang=apl inline>* Exponential
<source lang=apl inline>⍟ Natural Logarithm
<source lang=apl inline>| Magnitude
<source lang=apl inline>! Factorial
<source lang=apl inline>○ Pi Times
<source lang=apl inline>~ Not
<source lang=apl inline>∊ Type

Dyadic functions

<source lang=apl inline>+ Plus
<source lang=apl inline>- Minus
<source lang=apl inline>× Times
<source lang=apl inline>÷ Divide
<source lang=apl inline>⌊ Minimum
<source lang=apl inline>⌈ Maximum
<source lang=apl inline>* Power function
<source lang=apl inline>⍟ Logarithm
<source lang=apl inline>| Residue
<source lang=apl inline>! Binomial coefficient or combination function
<source lang=apl inline>○ Circle function
<source lang=apl inline>∧ Logical And
<source lang=apl inline>∨ Logical Or
<source lang=apl inline>⍲ Nand
<source lang=apl inline>⍱ Nor
<source lang=apl inline>< Less than
<source lang=apl inline>≤ Less than or equal to
<source lang=apl inline>= Equal to
<source lang=apl inline>≥ Greater than or equal to
<source lang=apl inline>> Greather than
<source lang=apl inline>≠ Not equal to