Elm Exactly

Basis entryBasics.max

A value of Basics. Its type is in Section C.3 Basics.

Static basis

var or con ↦ (σ,is)max, min ↦ (∀comparable. comparable→comparable  (∀comparable. →comparable,v)\begin{array}{|rcl|}\hline \var\ \text{or}\ \con {\ }& \mapsto {\ }& (\sigma, \is)\\\hline \href{/standard/basis/Basics/max}{\kw{max}},\ \href{/standard/basis/Basics/min}{\kw{min}} {\ }& \mapsto {\ }& (\forall\mv{comparable}.\,\mv{comparable} \rightarrow \mv{comparable}\\ {\ }& {\ }& \phantom{(\forall\mv{comparable}.\,}{} \rightarrow \mv{comparable}, \isv)\\\hline\end{array}
Figure 38: Static VE\VE of ME0(Basics)\ME_0(\kw{Basics}): Constructors, Conversions, Comparison, Booleans and Integer Functions

Dynamic basis

var or con ↦ varitymin, max ↦ basic value2\begin{array}{|rclc|}\hline \var\ \text{or}\ \con {\ }& \mapsto {\ }& v {\qquad}& \arity\\\hline \href{/standard/basis/Basics/min}{\kw{min}},\ \href{/standard/basis/Basics/max}{\kw{max}} {\ }& \mapsto {\ }& \text{basic value} {\qquad}& 2\\\hline\end{array}
Figure 45: Dynamic VE\VE of ME0(Basics)\ME_0(\kw{Basics})

Its APPLY

APPLY(max,x,y) = {NaN}if x or y is NaN = {+0}if x and y are zeros and one of them is +0 = {x}if x≥y = {y}otherwise.\begin{array}{rcll} \APPLY(\kw{max},x,y) {\ }& = {\ }& \{\dbNaN\} {\quad}& \text{if}\ x\ \text{or}\ y\ \text{is}\ \dbNaN\\ {\ }& = {\ }& \{+0\} {\quad}& \text{if}\ x\ \text{and}\ y\ \text{are zeros and one of them is}\ {+0}\\ {\ }& = {\ }& \{x\} {\quad}& \text{if}\ x\geq y\\ {\ }& = {\ }& \{y\} {\quad}& \text{otherwise}. \end{array}
APPLY(max,v,v′) = {v}if cmp(v,v′)=GT = {v′}otherwise,\begin{array}{rcll} \APPLY(\kw{max},v,v') {\ }& = {\ }& \{v\} {\quad}& \text{if}\ \dbcmp(v,v')=\kw{GT}\\ {\ }& = {\ }& \{v'\} {\quad}& \text{otherwise}, \end{array}
Read it in its chapter·Permanent address: /standard/basis/Basics/max

Tests (4)

  • elm-core / ComparableMinMaxTest
    `min` and `max` on `String` and `Char`, which order them by character code.
  • elm-core / FloatMinMaxTest
    `min` and `max` on Floats pick the smaller and larger argument, including with a negative argument.
  • elm-core / IntMinMaxTest
    Checks `min` and `max` on Int arguments, including a negative one.
  • elm-core / StandardA48MinMaxNanTest
    Float `min` and `max` are IEEE 754-2019 minimum and maximum, whatever the order of the arguments.

Discussions

Discuss this basis entry·Search the discussions on GitHub

Discussions are on GitHub; one about this basis entry has [b:Basics.max] in its title.

A Standard Definition of Elm? (Draft version 0.4) © Rupert Smith. The text is licensed under CC BY 4.0: share and adapt it freely, with credit and a link to the licence.