Question about managing list elements

Download0091 shared this question 6 years ago
Answered

Hello,


In a list like the following:


  1. SomeList = {(2, 4), (7, 5), (3, 7), (4, 5), (5, 9), (6, 4), (7, 8), (8, 5), (12, 6), (13, 3), (13, 4)}


and I would like to end up with a list that includes only the elements/points whose X coordinate occurs more than once. Like this:


  1. Result = {(7, 5), (7, 8), (13, 3), (13, 4)}


How can I do that ?


Thank you for your help,


John.

Best Answer
photo

Hi,

you can use Remove, Unique and KeepIf commands to do that

    list1=Remove[x(SomeList), Unique[x(SomeList)]]

    KeepIf[x(A)∈list1,A,SomeList]


Cheers,

Zbynek

Comments (2)

photo
1

Hi,

you can use Remove, Unique and KeepIf commands to do that

    list1=Remove[x(SomeList), Unique[x(SomeList)]]

    KeepIf[x(A)∈list1,A,SomeList]


Cheers,

Zbynek

photo
1

Very nice!


Thank you very much Zbynek.


John.

© 2023 International GeoGebra Institute