type Nat = Nat
Module Nat
Natural-number operations and iterators.
Nat.Clamp(x)(lo, hi) clamps x to the inclusive range [lo, hi].
dec Nat.FromString : [String] either { .err !, .ok Nat, }
Parses a decimal string into a natural number.
Returns .err! when the string is not a valid non-negative integer.
Nat.Max(n, m) returns the larger of n and m.
The result is always a Nat, even though m is an Int.
Returns the smaller of two natural numbers.
Nat.Mod(m, n) is the remainder of dividing m by n.
Returns 0 when n is 0.
Nat.Range(lo, hi) produces the naturals from lo (inclusive) to hi (exclusive).
Nat.Range(0, 4) // = *(0, 1, 2, 3)
Produces n repetitions of .step, followed by .end!.
Nat.Repeat(3).begin.case {
.end! => "done",
.step next => ... next.loop,
}
dec Nat.RepeatLazy : [Nat] recursive either { .end !, .step box choice { .next => self, }, }
Like Repeat, but each .step carries a boxed continuation behind .next.
Use it when later steps might not be needed.