crow/range.crow (source)
range[t] record
lowthight
Range of values. low is inclusive and high is exclusive.
Usable for any type with a comparison function.
forward-rangeable[t] spec t compare
compare+t(at,distancenat64)
subtract-to-nat[t] spec
-nat64(at,bt)
rangeable[t] spec t forward-rangeable, t subtract-to-nat
forward-rangeablesubtract-to-nat-t(at,distancenat64)
Spec for types that support most range operations
..[t] t range(low t, high t) bare, t compare
compareCreate a range from low (inclusive) to high (exclusive).
size[t] nat64(a t range) bare, t subtract-to-nat
subtract-to-natSize of the range; depends on a - function existing.
iterate[t] bool(a t range, f mut bool(t)) t forward-rangeable
forward-rangeableCalls f for each value in the range, from a.low to a.high - 1.
add-nat[t] spec
+t(at,nnat64)
==[t] bool(a t range, b t range) bare, t equal
equalis-empty[t] bool(a t range) bare, t equal
equalrange-iterator[t] record
(has non-public fields)
==[t] bool(a t range-iterator, b t range-iterator) bare, t equal
equal<=>[t] comparison(a t range-iterator, b t range-iterator) bare, t compare
compare-[t] nat64(a t range-iterator, b t range-iterator) t subtract-to-nat
subtract-to-nat+[t] t range-iterator(a t range-iterator, n nat64) t compare, t add-nat
compareadd-natslice[t] t range(a t range-iterator, b t range-iterator) t compare
comparebegin[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
rangeablenext[t] (t, t range-iterator) tuple2?(a t range-iterator) bare, t forward-rangeable
forward-rangeablein[t] bool(a t, b t range) bare, t compare
comparesubscript[t] t(a t range, index nat64) bare, t rangeable
rangeablesubscript[t] t range(a t range, indices nat64 range) bare, t rangeable
rangeableclamp[t] t(a t, range t range) bare, t rangeable
rangeable