Comparison function: Difference between revisions

Jump to navigation Jump to search
Fix two minor language issues and add link to jupyter notebook on the comparison functions.
Miraheze>Marshall
No edit summary
 
(Fix two minor language issues and add link to jupyter notebook on the comparison functions.)
(4 intermediate revisions by 3 users not shown)
Line 3: Line 3:
|}
|}


A '''comparison function''' is one of the six [[primitive function|primitive]] [[dyadic]] [[scalar function]]s whose result on scalars is a [[Boolean]] determined by the numerical ordering of the two [[argument]]s. Comparisons are subject to [[comparison tolerance]]. The comparison functions can be subdivided into two equalities <source lang=apl inline>=</source> <source lang=apl inline>≠</source>, which depend only on whether the arguments are equal and not the ordering of unequal argument, and may be applied to [[character]]s, and four inequalities <source lang=apl inline><</source> <source lang=apl inline>≤</source> <source lang=apl inline>≥</source> <source lang=apl inline>></source>, which depend on ordering and may not be applied to [[character]]s.
A '''comparison function''' is one of the six [[primitive function|primitive]] [[dyadic]] [[scalar function]]s whose result on scalars is a [[Boolean]] determined by the numerical ordering of the two [[argument]]s. Comparisons are subject to [[comparison tolerance]]. The comparison functions can be subdivided into two equalities <source lang=apl inline>=</source> <source lang=apl inline>≠</source>, which depend only on whether the arguments are equal and not on the ordering of the arguments, and may be applied to [[character]]s, and four inequalities <source lang=apl inline><</source> <source lang=apl inline>≤</source> <source lang=apl inline>≥</source> <source lang=apl inline>></source>, which depend on ordering and may not be applied to [[character]]s.


The six comparison functions are [[Less Than]] (<source lang=apl inline><</source>), [[Less Than or Equal]] (<source lang=apl inline>≤</source>), [[Equal to]] (<source lang=apl inline>=</source>), [[Greater Than or Equal]] (<source lang=apl inline>≥</source>), [[Greater Than]] (<source lang=apl inline>></source>), and [[Not Equal to]] (<source lang=apl inline>≠</source>).
The six comparison functions are [[Less Than]] (<source lang=apl inline><</source>), [[Less Than or Equal]] (<source lang=apl inline>≤</source>), [[Equal to]] (<source lang=apl inline>=</source>), [[Greater Than or Equal]] (<source lang=apl inline>≥</source>), [[Greater Than]] (<source lang=apl inline>></source>), and [[Not Equal to]] (<source lang=apl inline>≠</source>). You can take a closer look at how these six comparison functions behave in [https://nbviewer.jupyter.org/github/Dyalog/dyalog-jupyter-notebooks/blob/master/Closer%20look%20at%20the%20comparison%20functions.ipynb this APL Jupyter notebook].


Because comparison functions have Boolean results on Boolean arguments (they always have Boolean results), they are [[Boolean function]]s. In fact, the majority of nontrivial dyadic Boolean functions are comparison functions.
Because comparison functions have Boolean results on Boolean arguments (they always have Boolean results), they are [[Boolean function]]s. In fact, the majority of nontrivial dyadic Boolean functions are comparison functions.
Line 32: Line 32:


The traditional APL ordering of the comparison functions used above, which was used at least as early as [[APL\360]], resembles a [[wikipedia:Gray code|Gray code]] ordering of the values which define the comparison functions. Adjacent values differ by only a change of one bit, but the list is not a true Gray code because it excludes the all-0 and all-1 combinations.
The traditional APL ordering of the comparison functions used above, which was used at least as early as [[APL\360]], resembles a [[wikipedia:Gray code|Gray code]] ordering of the values which define the comparison functions. Adjacent values differ by only a change of one bit, but the list is not a true Gray code because it excludes the all-0 and all-1 combinations.
{{APL built-ins}}[[Category:Comparison functions| ]][[Category:Lists]]
18

edits

Navigation menu