2024-04-12 10:09:31 -07:00
|
|
|
struct Foo(x,y:Int)
|
2024-03-07 09:18:01 -08:00
|
|
|
|
2024-04-28 11:58:55 -07:00
|
|
|
func main():
|
2024-11-02 17:22:19 -07:00
|
|
|
>> (+: [10, 20, 30])
|
2024-11-21 10:00:53 -08:00
|
|
|
= 60 : Int?
|
2024-11-02 17:22:19 -07:00
|
|
|
|
|
|
|
>> (+: [:Int])
|
2024-11-21 10:00:53 -08:00
|
|
|
= NULL : Int?
|
2024-11-02 17:22:19 -07:00
|
|
|
|
|
|
|
>> (+: [10, 20, 30]) or 0
|
2024-04-12 10:09:31 -07:00
|
|
|
= 60
|
2024-03-07 09:18:01 -08:00
|
|
|
|
2024-11-02 17:22:19 -07:00
|
|
|
>> (+: [:Int]) or 0
|
|
|
|
= 0
|
|
|
|
|
|
|
|
>> (_max_: [3, 5, 2, 1, 4])
|
2024-11-21 10:00:53 -08:00
|
|
|
= 5 : Int?
|
2024-03-07 09:18:01 -08:00
|
|
|
|
2024-11-02 17:22:19 -07:00
|
|
|
>> (_max_:abs(): [1, -10, 5])
|
2024-11-21 10:00:53 -08:00
|
|
|
= -10 : Int?
|
2024-04-12 10:09:31 -07:00
|
|
|
|
2024-11-02 17:22:19 -07:00
|
|
|
>> (_max_: [Foo(0, 0), Foo(1, 0), Foo(0, 10)])!
|
2024-04-12 10:09:31 -07:00
|
|
|
= Foo(x=1, y=0)
|
2024-11-02 17:22:19 -07:00
|
|
|
>> (_max_.y: [Foo(0, 0), Foo(1, 0), Foo(0, 10)])!
|
2024-04-12 10:09:31 -07:00
|
|
|
= Foo(x=0, y=10)
|
2024-11-02 17:22:19 -07:00
|
|
|
>> (_max_.y:abs(): [Foo(0, 0), Foo(1, 0), Foo(0, 10), Foo(0, -999)])!
|
2024-04-12 10:09:31 -07:00
|
|
|
= Foo(x=0, y=-999)
|
2024-09-05 08:51:07 -07:00
|
|
|
|
|
|
|
!! (or) and (and) have early out behavior:
|
2024-11-02 19:34:35 -07:00
|
|
|
>> (or: i == 3 for i in 9999999999999999999999999999)!
|
|
|
|
= yes
|
2024-09-05 08:51:07 -07:00
|
|
|
|
2024-11-02 19:34:35 -07:00
|
|
|
>> (and: i < 10 for i in 9999999999999999999999999999)!
|
|
|
|
= no
|
|
|
|
|
|
|
|
>> (<=: [1, 2, 2, 3, 4])!
|
|
|
|
= yes
|
|
|
|
|
|
|
|
>> (<=: [:Int])
|
2024-11-21 10:00:53 -08:00
|
|
|
= NULL : Bool?
|
2024-11-02 19:34:35 -07:00
|
|
|
|
|
|
|
>> (<=: [5, 4, 3, 2, 1])!
|
|
|
|
= no
|