Consider this code:
proc generateTuples(a: int, b: int, bNext: int): [] {
var tuples: [1..?] (int,int);
for q in (b+1)..(bNext-1) {
tuples.push([a, q]);
}
return tuples;
}
proc mergeLists(l1: [(int,int)], l2: [(int,int)]): [(int,int)] {
var result: [1..?](int,int);
var i1:int = 1;
var i2:int = 1;
while ((i1 <= l1.size) && (i2 <= l2.size)) {
if l1[i1] < l2[i2] {
result.push(l1[i1]);
i1 += 1;
} else {
result.push(l2[i2]);
i2 = i2+1;
}
}
result.append(l1[i1..l1.size]);
result.append(l2[i2..l2.size]);
return result;
}
proc generateTuplesSub(L: [1..?](int,int), start: int, end: int): [] (int,int) {
writeln(start," ",end);
if end <start {
var b: [1..0] (int,int);
return b;
}
var mid: int = (start + end) / 2;
var aMid = L[mid][0];
var bMid = L[mid][1];
var tuplesLeft = generateTuplesSub(L, start, mid);
var tuplesRight = generateTuplesSub(L, mid, end);
// Merge the tuples generated for the left and right halves
var result = mergeLists(tuplesLeft, tuplesRight);
// Add the tuples generated for the (aMid, bMid) pair
if mid < end - 1 {
var bNext = L[mid+1][1];
var tuplesMid = generateTuples(aMid, bMid, bNext);
result = mergeLists(result, tuplesMid);
}
return result;
}
// Example usage
var L = [(0, 4), (1, 5), (2, 6), (3, 7), (4, 8), (5, 10), (6, 12)];
var numProcesses = L.size;
var result = generateTuplesSub(L, 1,7);
for tup in result {
writeln("(", tup[1], ", ", tup[2], ")");
}
It is written in Chapel programming language. I get the following error:
called as generateTuplesSub(L: [domain(1,int(64),false)] 2*int(64), start: int(64), end: int(64))
note: generic instantiations are underlined in the above callstack.
What does it mean? What should I do? I am compiling in with terminal of Mac. It looks like that there is a problem with the input type, but I do not understand it.
I get error when I want to compile it.