intersect - compute the set intersection of two arrays
arr0.intersect(arr1)
The intersect() method returns a 1D vector
containing elements that are present in both arr0
and arr1. It is similar to APL
arr0 ∩
arr1, although it differs in its treatment of
duplicate elements.
The resulting vector contains only unique elements, even if the inputs contain duplicates. The order of elements in the result is determined by their first appearance in arr0.
Note that both arr0 and arr1 are implicitly flattened before computing their intersction.
A 1D vector containing the common elements of arr0 and arr1.
None.
a = [1, 2, 3, 4]
b = [3, 4, 5, 6]
a.intersect(b)
3 4