[package] [Java implementation] [Execution output]


NestedLiterals


import church.lang.Array;

import church.util.HashSet;

import church.math.Vector;

/**
 * Examples of nested literals. Each literal is shown as the rhs of a variable assignment but, unlike Java,
 * being on the rhs of a variable assignment is not required and literals may appear anywhere in an expression.
 */
void: main(String[]: args) = {
    // Array<Array<int>>
    a0 = [[1, 2], [3, 4]];
    output << a0 << "\n";

    // Vector<Array<int>>
    v1 = <[1, 2], [3, 4]>;
    output << v1 << "\n";

    // Array<Vector<int>>
    a1 = [<1, 2>, <3, 4>];
    output << a1 << "\n";

    // Array<Set<int>>
    a2 = [{1, 2}, {3, 4}];
    output << a2 << "\n";

    // Set<Array<int>>
    s1 = {[1, 2], [3, 4]};
    output << s1 << "\n";
}