tomo/test/reductions.tm
Bruce Hill 34d98f067e For big or arbitrarily big integers not known to be constant, do full
Int$plus(a,b) logic so it's definitely correct and doesn't error.
2024-09-05 12:41:13 -04:00

26 lines
534 B
Tcl

struct Foo(x,y:Int)
func main():
>> (+) [10, 20, 30]
= 60
>> (_max_) [3, 5, 2, 1, 4]
= 5
>> (_max_:abs()) [1, -10, 5]
= -10
>> (_max_) [Foo(0, 0), Foo(1, 0), Foo(0, 10)]
= Foo(x=1, y=0)
>> (_max_.y) [Foo(0, 0), Foo(1, 0), Foo(0, 10)]
= Foo(x=0, y=10)
>> (_max_.y:abs()) [Foo(0, 0), Foo(1, 0), Foo(0, 10), Foo(0, -999)]
= Foo(x=0, y=-999)
!! (or) and (and) have early out behavior:
>> (or) i == 3 for i in 9999999999999999999999999999
= yes
>> (and) i < 10 for i in 9999999999999999999999999999
= no