crow/range.crow (source)

range[t] record

  • low t
  • high t

Range of values. low is inclusive and high is exclusive.

Usable for any type with a comparison function.

forward-rangeable[t] spec t compare

subtract-to-nat[t] spec

rangeable[t] spec t forward-rangeable, t subtract-to-nat

Spec for types that support most range operations

..[t] t range(low t, high t) bare, t compare

Create a range from low (inclusive) to high (exclusive).

size[t] nat64(a t range) bare, t subtract-to-nat

Size of the range; depends on a - function existing.

iterate[t] bool(a t range, f mut bool(t)) t forward-rangeable

Calls f for each value in the range, from a.low to a.high - 1.

add-nat[t] spec

==[t] bool(a t range, b t range) bare, t equal

is-empty[t] bool(a t range) bare, t equal

range-iterator[t] record

(has non-public fields)

    ==[t] bool(a t range-iterator, b t range-iterator) bare, t equal

    <=>[t] comparison(a t range-iterator, b t range-iterator) bare, t compare

    -[t] nat64(a t range-iterator, b t range-iterator) t subtract-to-nat

    +[t] t range-iterator(a t range-iterator, n nat64) t compare, t add-nat

    slice[t] t range(a t range-iterator, b t range-iterator) t compare

    begin[t] t range-iterator(a t range) bare

    end[t] t range-iterator(a t range) bare

    prev[t] (t range-iterator, t) tuple2?(a t range-iterator) bare, t rangeable

    next[t] (t, t range-iterator) tuple2?(a t range-iterator) bare, t forward-rangeable

    in[t] bool(a t, b t range) bare, t compare

    subscript[t] t(a t range, index nat64) bare, t rangeable

    subscript[t] t range(a t range, indices nat64 range) bare, t rangeable

    clamp[t] t(a t, range t range) bare, t rangeable