# Collection union/intersection/etc

**URL:** <https://discourse.julialang.org/t/collection-union-intersection-etc/54804>\
**Category:** General Usage\
**Created:** [February 7, 2021, 4:36pm UTC](https://discourse.julialang.org/t/collection-union-intersection-etc/54804 "2021-02-07T16:36:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fph](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fph/32/17159_2.png) [@fph](https://discourse.julialang.org/u/fph)\
**Post date:** [February 7, 2021, 4:36pm UTC](https://discourse.julialang.org/t/collection-union-intersection-etc/54804/1 "2021-02-07T16:36:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [February 8, 2021, 2:18pm UTC](https://discourse.julialang.org/t/collection-union-intersection-etc/54804/2 "2021-02-08T14:18:04Z")

</div>

> [@fph](#):
>
> for instance `sum` is the reduction form of `+`

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.
