2
的火卫一的文档显示传递给可变参数函数传递一个范围范围的可变参数函数
int[] a = [ 1, 2, 4, 5, 7, 9 ];
int[] b = [ 0, 1, 2, 4, 7, 8 ];
int[] c = [ 0, 1, 4, 5, 7, 8 ];
assert(equal(setIntersection(a, a), a));
assert(equal(setIntersection(a, b), [1, 2, 4, 7][]));
assert(equal(setIntersection(a, b, c), [1, 4, 7][]));
但如果你有一系列范围的下列范围例子,你不知道在提前多少元素它包含像
int[][] a = [[1,2,3,4],[1,2,4,5],[1,3,4,5]];
我能想到的唯一的事情就是
if (a.length > 1) {
auto res = array(setIntersection(a[0], a[1]));
for (int i = 2; i < a.length; i++)
res = array(setIntersection(res, a[i]));
writeln(res);
}
哪些工作。但我希望能够直接将参数传递给函数,比如setIntersection(a.tupleof)或类似的东西(我知道tupleof在这里不起作用)。