Collection union/intersection/etc

Some common binary operations come with a separate method that reduces a collection with it; for instance sum is the reduction form of + or prod is the reduction form of *. Is there a reduction form for intersect and union, i.e., functions that are equivalent to f(v) = reduce(intersect, v) and g(v) = reduce(union, v)?

It would make some sense to overload any and all to do this, if nothing exists already.

Mathematically yes, but technically not. sum also

  1. widens the result, eg typeof(sum(rand(Int8, 4))) == Int,
  2. has the freedom to choose a more clever/accurate algorithm if applicable (eg pairwise summation).

Unless these apply for intersect and union (which I don’t think is the case), introducing functions for the reduction is not warranted.

2 Likes