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
compare
+
t
(a
t
,distance
nat64
)
subtract-to-nat
[t
] spec
-
nat64
(a
t
,b
t
)
rangeable
[t
] spec
t
forward-rangeable
, t
subtract-to-nat
forward-rangeable
subtract-to-nat
-
t
(a
t
,distance
nat64
)
Spec for types that support most range operations
..
[t
] t
range
(low
t
, high
t
) bare
, t
compare
compare
Create a range from low
(inclusive) to high
(exclusive).
size
[t
] nat64
(a
t
range
) bare
, t
subtract-to-nat
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
forward-rangeable
Calls f
for each value in the range, from a.low
to a.high - 1
.
add-nat
[t
] spec
+
t
(a
t
,n
nat64
)
==
[t
] bool
(a
t
range
, b
t
range
) bare
, t
equal
equal
is-empty
[t
] bool
(a
t
range
) bare
, t
equal
equal
range-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
compare
add-nat
slice
[t
] t
range
(a
t
range-iterator
, b
t
range-iterator
) t
compare
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
rangeable
next
[t
] (t
, t
range-iterator
) tuple2
?
(a
t
range-iterator
) bare
, t
forward-rangeable
forward-rangeable
in
[t
] bool
(a
t
, b
t
range
) bare
, t
compare
compare
subscript
[t
] t
(a
t
range
, index
nat64
) bare
, t
rangeable
rangeable
subscript
[t
] t
range
(a
t
range
, indices
nat64
range
) bare
, t
rangeable
rangeable
clamp
[t
] t
(a
t
, range
t
range
) bare
, t
rangeable
rangeable