1 //////////////////////////////////////////////////////////////////////////////
3 // Testing all the list constructors.
5 //////////////////////////////////////////////////////////////////////////////
8 //////////////////////////////////////////////////////////////////////////////
9 // Define some list types.
10 // I'm lazy so I just let the system to generate the printing methods.
11 //////////////////////////////////////////////////////////////////////////////
12 datatype LIST1 :: printable = #[] | #[ char * ... LIST1 ]
13 and LIST2 :: printable = #() | #( char * ... LIST2 )
14 and LIST3 :: printable = #{} | #{ char * ... LIST3 }
17 instantiate datatype LIST1, LIST2, LIST3;
19 //////////////////////////////////////////////////////////////////////////////
20 // Try the new list constructor in expressions.
21 //////////////////////////////////////////////////////////////////////////////
24 { LIST1 fruits = #["apple", "orange", "pear"];
25 LIST1 scums = #["marketing", "lawyers", "Republicans"];
26 LIST1 animals = #["weasels", "skunks" ... scums];
27 cout << "Fruits = " << fruits << '\n';
28 cout << "Animals = " << animals << '\n';
29 cout << "Mathematicans = " << #["Skolem", "Curry", "Thue", "Church"] << '\n';
32 { LIST2 fruits = #("apple", "orange", "pear");
33 LIST2 scums = #("marketing", "lawyers", "Republicans");
34 LIST2 animals = #("weasels", "skunks" ... scums);
35 cout << "Fruits = " << fruits << '\n';
36 cout << "Animals = " << animals << '\n';
37 cout << "Mathematicans = " << #("Skolem", "Curry", "Thue", "Church") << '\n';
40 { LIST3 fruits = #{"apple", "orange", "pear"};
41 LIST3 scums = #{"marketing", "lawyers", "Republicans"};
42 LIST3 animals = #{"weasels", "skunks" ... scums};
43 cout << "Fruits = " << fruits << '\n';
44 cout << "Animals = " << animals << '\n';
45 cout << "Mathematicans = " << #{"Skolem", "Curry", "Thue", "Church"} << '\n';
49 LIST4 fruits = #<"apple", "orange", "pear">;
50 LIST4 scums = #<"marketing", "lawyers", "Republicans">;
51 LIST4 animals = #<"weasels", "skunks" ... scums>;
52 cout << "Fruits = " << fruits << '\n';
53 cout << "Animals = " << animals << '\n';
54 cout << "Mathematicans = " << #<"Skolem", "Curry", "Thue", "Church"> << '\n';