Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to identify different members?

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)]

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading