Difference between revisions of "Scalar function"

From APL Wiki
Jump to navigation Jump to search
Miraheze>Marshall
Miraheze>Adám Brudzewsky
m (Text replacement - "<code>" to "<source lang=apl inline>")
Line 1: Line 1:
 
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 model|nested]] array languages scalar functions recursively descend into nested arrays until they can be applied to [[simple scalars]]; in [[Flat array model|flat]] array languages they usually do not apply inside [[boxes]].
 
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 model|nested]] array languages scalar functions recursively descend into nested arrays until they can be applied to [[simple scalars]]; in [[Flat array model|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 <code>~</code> with non-scalar dyad [[Without]], and similarly scalar [[Roll]] and non-scalar [[Deal]] are both written <code>?</code>.
+
Only a particular [[valence]] of a function is labelled "scalar". The scalar monad [[Not]] usually shares the glyph <source lang=apl inline>~</code> with non-scalar dyad [[Without]], and similarly scalar [[Roll]] and non-scalar [[Deal]] are both written <source lang=apl inline>?</code>.
  
 
== Standard scalar functions ==
 
== Standard scalar functions ==
Line 10: Line 10:
  
 
{|
 
{|
| <code>+</code> || [[Conjugate]]
+
| <source lang=apl inline>+</code> || [[Conjugate]]
 
|-
 
|-
| <code>-</code> || [[Negate]]
+
| <source lang=apl inline>-</code> || [[Negate]]
 
|-
 
|-
| <code>×</code> || [[Signum]] or Direction
+
| <source lang=apl inline>×</code> || [[Signum]] or Direction
 
|-
 
|-
| <code>÷</code> || [[Reciprocal]]
+
| <source lang=apl inline>÷</code> || [[Reciprocal]]
 
|-
 
|-
| <code>⌊</code> || [[Floor]]
+
| <source lang=apl inline>⌊</code> || [[Floor]]
 
|-
 
|-
| <code>⌈</code> || [[Ceiling]]
+
| <source lang=apl inline>⌈</code> || [[Ceiling]]
 
|-
 
|-
| <code>*</code> || [[Exponential]]
+
| <source lang=apl inline>*</code> || [[Exponential]]
 
|-
 
|-
| <code>⍟</code> || [[Natural Logarithm]]
+
| <source lang=apl inline>⍟</code> || [[Natural Logarithm]]
 
|-
 
|-
| <code><nowiki>|</nowiki></code> || [[Magnitude]]
+
| <source lang=apl inline><nowiki>|</nowiki></code> || [[Magnitude]]
 
|-
 
|-
| <code>!</code> || [[Factorial]]
+
| <source lang=apl inline>!</code> || [[Factorial]]
 
|-
 
|-
| <code>○</code> || [[Pi Times]]
+
| <source lang=apl inline>○</code> || [[Pi Times]]
 
|-
 
|-
| <code>~</code> || [[Not]]
+
| <source lang=apl inline>~</code> || [[Not]]
 
|-
 
|-
| <code>∊</code> || [[Type]]
+
| <source lang=apl inline>∊</code> || [[Type]]
 
|}
 
|}
  
Line 40: Line 40:
  
 
{|
 
{|
| <code>+</code> || [[Plus]]
+
| <source lang=apl inline>+</code> || [[Plus]]
 
|-
 
|-
| <code>-</code> || [[Minus]]
+
| <source lang=apl inline>-</code> || [[Minus]]
 
|-
 
|-
| <code>×</code> || [[Times]]
+
| <source lang=apl inline>×</code> || [[Times]]
 
|-
 
|-
| <code>÷</code> || [[Divide]]
+
| <source lang=apl inline>÷</code> || [[Divide]]
 
|-
 
|-
| <code>⌊</code> || [[Minimum]]
+
| <source lang=apl inline>⌊</code> || [[Minimum]]
 
|-
 
|-
| <code>⌈</code> || [[Maximum]]
+
| <source lang=apl inline>⌈</code> || [[Maximum]]
 
|-
 
|-
| <code>*</code> || [[Power function]]
+
| <source lang=apl inline>*</code> || [[Power function]]
 
|-
 
|-
| <code>⍟</code> || [[Logarithm]]
+
| <source lang=apl inline>⍟</code> || [[Logarithm]]
 
|-
 
|-
| <code><nowiki>|</nowiki></code> || [[Residue]]
+
| <source lang=apl inline><nowiki>|</nowiki></code> || [[Residue]]
 
|-
 
|-
| <code>!</code> || [[Binomial]] coefficient or combination function
+
| <source lang=apl inline>!</code> || [[Binomial]] coefficient or combination function
 
|-
 
|-
| <code>○</code> || [[Circle function]]
+
| <source lang=apl inline>○</code> || [[Circle function]]
 
|-
 
|-
| <code>∧</code> || [[Logical And]]
+
| <source lang=apl inline>∧</code> || [[Logical And]]
 
|-
 
|-
| <code>∨</code> || [[Logical Or]]
+
| <source lang=apl inline>∨</code> || [[Logical Or]]
 
|-
 
|-
| <code>⍲</code> || [[Nand]]
+
| <source lang=apl inline>⍲</code> || [[Nand]]
 
|-
 
|-
| <code>⍱</code> || [[Nor]]
+
| <source lang=apl inline>⍱</code> || [[Nor]]
 
|-
 
|-
| <code><</code> || [[Less than]]
+
| <source lang=apl inline><</code> || [[Less than]]
 
|-
 
|-
| <code>≤</code> || [[Less than or equal to]]
+
| <source lang=apl inline>≤</code> || [[Less than or equal to]]
 
|-
 
|-
| <code>=</code> || [[Equal to]]
+
| <source lang=apl inline>=</code> || [[Equal to]]
 
|-
 
|-
| <code>≥</code> || [[Greater than or equal to]]
+
| <source lang=apl inline>≥</code> || [[Greater than or equal to]]
 
|-
 
|-
| <code>></code> || [[Greather than]]
+
| <source lang=apl inline>></code> || [[Greather than]]
 
|-
 
|-
| <code>≠</code> || [[Not equal to]]
+
| <source lang=apl inline>≠</code> || [[Not equal to]]
 
|}
 
|}

Revision as of 09:06, 29 October 2019

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