Module Int

Integer operations.

type Int = Int
dec Int.Abs : [Int] Nat

Returns the absolute value of an integer as a natural number.

dec Int.Clamp : [Int, Int, Int] Int

Int.Clamp(x)(lo, hi) clamps x to the inclusive range [lo, hi].

Int.Clamp(7)(0, 5)   // = 5
Int.Clamp(-3)(0, 5)  // = 0
dec Int.FromString : [String] either {
  .err !,
  .ok Int,
}

Parses a decimal string into an integer. Returns .err! when the string is not a valid integer.

dec Int.Max : [Int, Int] Int

Returns the larger of two integers.

dec Int.Min : [Int, Int] Int

Returns the smaller of two integers.

dec Int.Mod : [Int, Nat] Nat

Int.Mod(x, n) returns the non-negative remainder of x modulo n. The result is in [0, n), or 0 when n is 0.

dec Int.Range : [Int, Int] List<Int>

Int.Range(lo, hi) produces the integers from lo (inclusive) to hi (exclusive).

Int.Range(0, 5)  // = *(0, 1, 2, 3, 4)