I'm guessing that containers will help with this, but I'm not sure how.
Say I have an int[][] of unknown length and I want to get the setIntersection
of all int[]s. The only way I can see to do that is to intersect the first two
elements and iterate over them storing into an int[] which can be used in an
intersection with the next element...
I realize that a Range is meant to be view of a container, but it seems to me
that containing a Range can be just as useful. How might containers improve
this situation?
-----------------------------------
import std.algorithm;
void main() {
auto lists = [[1,2,3,4,5],
[2,4,6,8,10],
[1,1,2,3,5]];
//assert(setIntersection(lists) == [2]);
auto result = setIntersection(lists[0], lists[1]);
foreach(range; lists)
result = setIntersection(result, range);
}
-------------------------------
.\setint.d(13): Error: cannot implicitly convert expression (setIntersection(res
ult,range)) of type SetIntersection!(less,SetIntersection!(less,int[],int[]),int
[]) to SetIntersection!(less,int[],int[])