How to find all different elements in two vectors ( with same or not same size). For instance:
t1 = [(1,2,3), (1,2,4),(2,5,1),(2,5,2)]
t2 = [(1,2,3), (1,2,8),(2,5,1),(2,5,2)]
How to create another vector diff_t such that
diff_t = [(1,2,8)]
How to find all different elements in two vectors ( with same or not same size). For instance:
t1 = [(1,2,3), (1,2,4),(2,5,1),(2,5,2)]
t2 = [(1,2,3), (1,2,8),(2,5,1),(2,5,2)]
How to create another vector diff_t such that
diff_t = [(1,2,8)]
julia> setdiff(t2, t1)
1-element Vector{Tuple{Int64, Int64, Int64}}:
(1, 2, 8)
This will give you all the elements that are present in t2, but not present in t1.
julia> symdiff(t1, t2)
2-element Vector{Tuple{Int64, Int64, Int64}}:
(1, 2, 4)
(1, 2, 8)
This is "symmetric difference", so it returns the list of all elements, whether from t1 or t2, that are not present in the other array.
This might be more than 10X faster than a setdiff:
filter(∉(t1),t2)
1-element Vector{Tuple{Int64, Int64, Int64}}:
(1, 2, 8)