Elm Exactly

Basis entryBasics.negate

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

Static basis

var or con ↦ (σ,is)negate, abs ↦ (∀number. number→number,v)\begin{array}{|rcl|}\hline \var\ \text{or}\ \con {\ }& \mapsto {\ }& (\sigma, \is)\\\hline \href{/standard/basis/Basics/negate}{\kw{negate}},\ \href{/standard/basis/Basics/abs}{\kw{abs}} {\ }& \mapsto {\ }& (\forall\mv{number}.\,\mv{number} \rightarrow \mv{number}, \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 ↦ varitynegate ↦ basic value1\begin{array}{|rclc|}\hline \var\ \text{or}\ \con {\ }& \mapsto {\ }& v {\qquad}& \arity\\\hline \href{/standard/basis/Basics/negate}{\kw{negate}} {\ }& \mapsto {\ }& \text{basic value} {\qquad}& 1\\\hline\end{array}
Figure 45: Dynamic VE\VE of ME0(Basics)\ME_0(\kw{Basics})

Its APPLY

APPLY(negate,n) = {norm(−n)}\begin{array}{rcll} \APPLY(\kw{negate},n) {\ }& = {\ }& \{\norm(-n)\} {\quad}& \end{array}
Figure 49: APPLY\APPLY on Int Values
APPLY(negate,x) = {NaN}if x is NaN = {(−1)⋅x}otherwise\begin{array}{rcll} \APPLY(\kw{negate},x) {\ }& = {\ }& \{\dbNaN\} {\quad}& \text{if}\ x\ \text{is}\ \dbNaN\\ {\ }& = {\ }& \{(-1)\cdot x\} {\quad}& \text{otherwise}\end{array}
Figure 50: APPLY\APPLY on Floats: Arithmetic
Read it in its chapter·Permanent address: /standard/basis/Basics/negate

Tests (7)

  • elm / InfixPrecApplicationFirstTest
    Application binds more tightly than any operator.
  • elm-core / FloatNegateTest
    `negate` flips the sign of a positive and a negative Float, and `negate 0.0` prints as 0.
  • elm-core / FloatNegativeZeroTest
    Negative zero (`-0.0`) equals 0.0, and dividing 1.0 by it gives -Infinity while dividing by 0.0 gives Infinity.
  • elm-core / FloatSubTest
    Float subtraction gives the expected value, including when the right operand is a negative literal.
  • elm-core / IntNegateTest
    Checks `negate` on a positive Int, a negative Int and zero.
  • elm-core / IntSubTest
    Checks integer subtraction `-`, including subtracting a negative literal.
  • elm-core / StandardA45IntNegativeZeroTest
    Int has one zero: no Int operation gives a negative zero.

Discussions

Discuss this basis entry·Search the discussions on GitHub

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