Open skaller opened 6 years ago
Partial implementation: this works with new syntax and classes:
instance Eq[5] {
fun == (x:5,y:5) => caseno x == caseno y;
}
instance Tord[5] {
fun < (x:5,y:5) => caseno x < caseno y;
}
instance BoundedTordForward[5] {
fun maxval () => `4:5;
}
instance BoundedTordBidirectional[5] {
fun minval () => `2:5;
}
instance BoundedTordRandom[5] {
fun + (x:5,y:5) => (caseno x + caseno y) :>> 5;
fun - (x:5,y:5) => (caseno x - caseno y) :>> 5;
fun one () => `1:5;
fun zero () => `0:5;
}
var x = ..[5];
for i in x perform println$ i._strr;
but needs to be generalised so the instance applies to UNITSUM kind, which doesn't yet work.
At present you can loop through an integer slice:
and an array with a compact linear index:
but there is no way to iterate through a compact linear type.