File: tuples.nice

package info (click to toggle)
nice 0.9.13-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 7,284 kB
  • ctags: 6,893
  • sloc: java: 42,767; xml: 3,508; lisp: 1,084; sh: 742; makefile: 670; cpp: 21; awk: 3
file content (42 lines) | stat: -rw-r--r-- 820 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package regtest.basic;

// Tuples

void test_tuples()
{
  println("\n### Testing tuples ###\n");

  (String, String) cs = ("world!", "Hello, ");
  String s1;
  String s2;
  s1 = " toto";
  (s1, s2) = cs;
  (s1, s2) = (s2, s1);
  println(s1 + s2);

  int a;
  int b;
  (a,b) = min_max(17, 14);
  println("" + a + " < " + b);

  (int, long) t1 = (a,b);
  (long, long) t2;
  t2 = t1;

  // Different array types must be generated depending on the context
  // This is similar to literal arrays
  (byte b1, byte b2) = (1, 2);
  (int x, int y) = (1,2);
  (b1, y) = (1, 2);
  (x, b2) = (1, 2);
  (x, String s) = (1, "Heterogenous tuple");

  (x, y) = (3,4);
  (int z, y) = (y,x);

  println("x,y,z = " + x + y + z);

  // create a tuple without using it
  // This is not parsed correctly now, but do we care?
  //(1, 2, 3);
}