Elm Exactly

Basis entryBasics.remainderBy

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

Static basis

var or con ↦ (σ,is)modBy, remainderBy ↦ (Int→Int→Int,v)\begin{array}{|rcl|}\hline \var\ \text{or}\ \con {\ }& \mapsto {\ }& (\sigma, \is)\\\hline \href{/standard/basis/Basics/modBy}{\kw{modBy}},\ \href{/standard/basis/Basics/remainderBy}{\kw{remainderBy}} {\ }& \mapsto {\ }& (\tInt \rightarrow \tInt \rightarrow \tInt, \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 ↦ varitymodBy, remainderBy ↦ basic value2\begin{array}{|rclc|}\hline \var\ \text{or}\ \con {\ }& \mapsto {\ }& v {\qquad}& \arity\\\hline \href{/standard/basis/Basics/modBy}{\kw{modBy}},\ \href{/standard/basis/Basics/remainderBy}{\kw{remainderBy}} {\ }& \mapsto {\ }& \text{basic value} {\qquad}& 2\\\hline\end{array}
Figure 45: Dynamic VE\VE of ME0(Basics)\ME_0(\kw{Basics})

Its APPLY

APPLY(remainderBy,n,m) = {m−n⋅trunc(m/n)}if n≠0 = {0}if n=0\begin{array}{rcll} \APPLY(\kw{remainderBy},n,m) {\ }& = {\ }& \{m-n\cdot\dbtrunc(m/n)\} {\quad}& \text{if}\ n\neq 0\\ {\ }& = {\ }& \{0\} {\quad}& \text{if}\ n=0\end{array}
Figure 49: APPLY\APPLY on Int Values
Read it in its chapter·Permanent address: /standard/basis/Basics/remainderBy

Tests (5)

  • elm / StandardCoreEvaluationExamplesTest
    Small programs for rules of the dynamic semantics of the Core that other tests reach only in passing, and examples from the Comments of A Standard Definition of Elm?, Chapter 6.
  • elm-core / IntRemainderByTest
    Checks that `remainderBy` gives a result with the sign of the dividend, for all four sign combinations of divisor and dividend.
  • elm-core / StandardA42RemainderByZeroTest
    `remainderBy 0 x` is `0`.
  • elm-core / StandardA42ZeroDivisorTest
    `3 // 0`, `modBy 0 3` and `remainderBy 0 3` are all `0`: the examples A Standard Definition of Elm? gives for ruling A42 in its initial dynamic basis.
  • 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.remainderBy] 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.