1 #!/bin/bash
2
3 #### tuple comparison
4 var t1 = 3, 0
5 var t2 = 4, 0
6 var t3 = 3, 1
7
8 if (t2 > t1) { echo yes1 }
9 if (t3 > t1) { echo yes2 }
10 if ( (0,0) > t1) { echo yes3 }
11
12 # NOTE: ((0,0) causes problems -- it looks like a shell statement!
13 #if ( (0,0) > t1) { echo yes3 }
14 ## STDOUT:
15 yes1
16 yes2
17 ## END
18
19
20 #### tuple literal doesn't conflict with ((
21 if ((0,0) < (0,1)) { echo yes }
22 ## STDOUT:
23 yes
24 ## END
25
26 #### Empty tuple
27 var t = ()
28 echo length=$len(t)
29 ## STDOUT:
30 length=0
31 ## END
32
33 #### Singleton tuple
34 var t = tup(42)
35 echo "length = $[len(t)]"
36 echo "t[0] = $[t[0]]"
37
38 # NOT ALLOWED. Use tup() instead.
39 #var t1 = 1,
40 var t2 = (1,)
41 ## status: 2
42 ## STDOUT:
43 length = 1
44 t[0] = 42
45 ## END