using std.algorithm to find intersection of DateTime[][] arg

Artem Tarasov via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Sep 9 23:53:22 PDT 2015


On Wednesday, 9 September 2015 at 20:28:35 UTC, Laeeth Isharc 
wrote:
>
> so setIntersection(arg[0],arg[1],arg[2] .. arg[$-1])
> except that I don't know how many series are in arg at compile 
> time.
>
> what's the most efficient way to use Phobos to find these?  (I 
> could write a loop, but I am trying to learn how to use 
> std.algorithm better).

I'd use something like this, it works in O(Σ|arg[i]| * 
log|arg.length|)
> arg.nWayUnion.group.filter!(g => g[1] == arg.length).map!(g => 
> g[0]).array


More information about the Digitalmars-d-learn mailing list