Nat
Natural numbers
Most operations on natural numbers (e.g. addition) are available as built-in operators (e.g. 1 + 1
). This module provides equivalent functions and Text
conversion.
Nat
type Nat = Prim.Types.Nat
Infinite precision natural numbers.
toText
let toText : Nat -> Text
Conversion.
min
func min(x : Nat, y : Nat) : Nat
Returns the minimum of x
and y
.
max
func max(x : Nat, y : Nat) : Nat
Returns the maximum of x
and y
.
equal
func equal(x : Nat, y : Nat) : Bool
Returns x == y
.
notEqual
func notEqual(x : Nat, y : Nat) : Bool
Returns x != y
.
less
func less(x : Nat, y : Nat) : Bool
Returns x < y
.
lessOrEqual
func lessOrEqual(x : Nat, y : Nat) : Bool
Returns x ⇐ y
.
greater
func greater(x : Nat, y : Nat) : Bool
Returns x > y
.
greaterOrEqual
func greaterOrEqual(x : Nat, y : Nat) : Bool
Returns x >= y
.
compare
func compare(x : Nat, y : Nat) : {#less; #equal; #greater}
Returns the order of x
and y
.
add
func add(x : Nat, y : Nat) : Nat
Returns the sum of x
and y
, x + y
.
sub
func sub(x : Nat, y : Nat) : Nat
Returns the difference of x
and y
, x - y
. Traps on underflow.
mul
func mul(x : Nat, y : Nat) : Nat
Returns the product of x
and y
, x * y
.
div
func div(x : Nat, y : Nat) : Nat
Returns the division of x
by y
, x / y
. Traps when y
is zero.
rem
func rem(x : Nat, y : Nat) : Nat
Returns the remainder of x
divided by y
, x % y
. Traps when y
is zero.
pow
func pow(x : Nat, y : Nat) : Nat
Returns x
to the power of y
, x ** y
.