var int i;


// multi-dimensional array
var int[][][] arr3;
arr3 := [
    [[1,0],
     [0,1]],
    [[1,1],
     [0,1]],
    [[3,2],
     [2,3]]
];

arr3[0][0][0] := arr3[2][0][1] := 1337;

print(arr3[2][0][1]);



// array passing
var int[][] target; target := array(int[], 2, 0);

function int[] populate(int start) {
    var int[] arr; arr := array(int, 4, 0);
    var int i; i := 0;

    while i < 4 do
        arr[i] := start+i;
        i := i+1;
    od;
    arr
};

i := 0;
while i < 2 do
    target[i] := populate(10*i);
    i := i+1;
od;

print(target[1][3]);


var target target2;
target2 := target;

var int[] firstRow; firstRow := array(int, 4, 0);
firstRow := target2[0];

print(firstRow[2]);



// function array
function int[] mapArray((int)->int f, int[] arr) {
    var int[] newArr; newArr := array(int, arr.length, arr.offset);
    var int i; i := 0;
    while i < arr.length do
        newArr[i] := f(arr[i]);
        i := i+1;
    od;
    newArr
};

function int increment(int a) a+1;

var int[] myArray; myArray := array(int, 9, 0);

i := 0;
while i < myArray.length do
    myArray[i] := i*i+10;
    i := i+1;
od;

myArray := mapArray(increment, myArray);

print(myArray[2]);

