A pure Elm library for computing with the integers, ℤ = { ..., -2, -1, 0, 1, 2, ... }.
negativeTennegativeNinenegativeEightnegativeSevennegativeSixnegativeFivenegativeFournegativeThreenegativeTwonegativeOnezeroonetwothreefourfivesixseveneightninetenInt or a NaturalfromSafeIntfromIntfromNaturalStringfromSafeStringfromStringfromBinaryStringfromOctalStringfromDecimalStringfromHexStringfromBaseBString==/=compareisLessThanisLessThanOrEqualisGreaterThanisGreaterThanOrEqualmaxminisNegative (i.e. < 0)isNonNegative (i.e. >= 0)isZero (i.e. == 0)isNonZero (i.e. /= 0)isPositive (i.e. > 0)isNonPositive (i.e. <= 0)isEvenisOddabsnegateaddsubmuldivModBy (Euclidean division)divBymodByquotRemBy (differs from divModBy in its handling of negative operands)quotByremByexpInt or a NaturaltoInttoNaturalN.B. Please remember to use them with caution since they discard information.
StringtoString (same as toDecimalString)toBinaryStringtoOctalStringtoDecimalStringtoHexStringtoBaseBStringIn the examples/calculator directory you will find the implementation of a simple integer calculator web application. The calculator
is designed and built to make it easy to test out all the integer input formats, arithmetic operations, and
integer output formats that's supported by this library.
You are able to enter your expression using an S-expression based language. The following syntax is supported:
Expr ::= Integer
| '(' 'abs' Expr ')'
| '(' 'negate' Expr ')'
| '(' 'add' Expr* ')'
| '(' 'sub' Expr Expr ')'
| '(' 'mul' Expr* ')'
| '(' 'div' Expr Expr ')'
| '(' 'mod' Expr Expr ')'
| '(' 'quot' Expr Expr ')'
| '(' 'rem' Expr Expr ')'
| '(' 'exp' Expr Expr ')'
Integer ::= Sign Magnitude
Sign ::= '-'?
Magnitude ::= ('0b' | '0B') Binary
| ('0o' | '0O') Octal
| ('0x' | '0X') Hex
| Decimal
Binary ::= [0-1]+
Octal ::= [0-7]+
Hex ::= [0-9a-fA-F]+
Decimal ::= [0-9]+N.B. You must be in the Nix development shell (nix develop) to run the scripts mentioned below.
Build the calculator web application.
$ build-examples-calculatorServe the calculator web application.
$ serve-examples-calculatorThen, open http://localhost:8000 in your browser to run the calculator.
TL;DR The performance of this library depends solely on the performance of elm-natural.
This library is built on elm-natural and each function that is implemented using functions from elm-natural only introduces
a constant amount of overhead. As a result, the performance characteristics of a given function, f, from this library are
directly related to
the performance characteristics of the functions from elm-natural
that are used to implement f. Practically speaking, this means that any performance gains in elm-natural will necessarily
lead to corresponding performance gains within elm-integer.