Elm Exactly

Basis entryBasics.sub

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

Static basis

op stands for ↦ OTSTAT(op)+, - add, sub ↦ (∀number. number→number→number,v)\begin{array}{|clcl|}\hline \opv {\ }& \text{stands for} {\ }& \mapsto {\ }& \OTstat(\opv)\\\hline \kw{+},\ \kw{-} {\ }& \href{/standard/basis/Basics/add}{\kw{add}},\ \href{/standard/basis/Basics/sub}{\kw{sub}} {\ }& \mapsto {\ }& (\forall\mv{number}.\,\mv{number} \rightarrow \mv{number} \rightarrow \mv{number}, \isv)\\\hline\end{array}
Figure 40: The Static Operator Table, OTSTAT\OTstat

Dynamic basis

opstands for ↦ OTDYN(op)arity+, -add, sub ↦ basic value2\begin{array}{|clclc|}\hline \opv {\quad}& \text{stands for} {\ }& \mapsto {\ }& \OTdyn(\opv) {\qquad}& \arity\\\hline \kw{+},\ \kw{-} {\quad}& \href{/standard/basis/Basics/add}{\kw{add}},\ \href{/standard/basis/Basics/sub}{\kw{sub}} {\ }& \mapsto {\ }& \text{basic value} {\qquad}& 2\\\hline\end{array}
Figure 46: The Dynamic Operator Table, OTDYN\OTdyn

Its APPLY

APPLY(sub,m,n) = {norm(m−n)}\begin{array}{rcll} \APPLY(\kw{sub},m,n) {\ }& = {\ }& \{\norm(m-n)\} {\quad}& \end{array}
Figure 49: APPLY\APPLY on Int Values
APPLY(sub,x,y) = APPLY(add,x,z)where APPLY(negate,y)={z}\begin{array}{rcll} \APPLY(\kw{sub},x,y) {\ }& = {\ }& \APPLY(\kw{add},x,z) {\quad}& \text{where}\ \APPLY(\kw{negate},y)=\{z\}\end{array}
Figure 50: APPLY\APPLY on Floats: Arithmetic
Read it in its chapter·Permanent address: /standard/basis/Basics/sub

Tests (5)

  • elm / InfixAssocLeftArithTest
    `-`, `/` and `//` associate to the left.
  • elm / InfixNegatedOperandTest
    A negation symbol in an operator chain negates the atomic expression after it, and no more.
  • elm-core / FloatSubTest
    Float subtraction gives the expected value, including when the right operand is a negative literal.
  • elm-core / IntSubTest
    Checks integer subtraction `-`, including subtracting a negative literal.
  • elm-core / StandardA40IntOverflowTest
    Int `+`, `-` and `*` give an Int, never an infinity or NaN, however large the exact result.

Discussions

Discuss this basis entry·Search the discussions on GitHub

Discussions are on GitHub; one about this basis entry has [b:Basics.sub] 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.