On Wednesday, 9 September 2015 at 20:28:35 UTC, Laeeth Isharc wrote:
I have a DateTime[][] arg ...
I would like to find the intersection of the dates.

A suggestion:

auto minLength      = arg.map!(a => a.length).reduce!min;
auto minIdx = arg.map!(a => a.length).countUntil(minLength); auto intersection = arg[minIdx].filter!(e => chain(arg[0..minIdx], arg[minIdx..$]).all!(a => a.assumeSorted.contains(e)));

reduce with setIntersection seems the most straightforward, but needs array AFAIK, i.e.:

auto intersection =
//reduce!((r, x) => setIntersection(r, x))(arg); // doesn't work reduce!((r, x) => setIntersection(r, x).array)(arg);// does, but with array

Reply via email to