Set intersection produces a new set containing only the elements shared by two or more sets. In Julia, write it as ∩ or call intersect; it acts like logical AND because an element must belong to every intersected set. section 13.3
Use intersection when a result must satisfy multiple membership conditions:
- Find pictures of Bob taken in either Spain or Greece with Bob ∩ (Spain ∪ Greece). section 13.3
- Find items shared by two sets with intersect(A, B) or A ∩ B. section 13.3
- Combine several criteria by intersecting intermediate results, such as (bob ∪ eve) ∩ joe. section 13.3
Finding shared values
With A = Set([1, 2, 4, 6]) and B = Set([1, 3, 5, 6]), A ∩ B returns the set containing 1 and 6. The function form, intersect(A, B), returns the same result. For caption sets, bob ∩ joe finds "Joe and Bob in Florida".
A Venn diagram makes the result intuitive: shade only the overlapping region of the sets. section 13.3




