2

I have a list like the following:

 {{1, 3}, {2, 5}, {3, 6}, {2, 4}}

I want the final list to be like that :

{{1, 3}, {2, 5}, {3, 6}}.

Here the first element of the sub list is needs to check with other sub list's first element and remove the sub list where first element repeated again.

So the final list doesn't have {2,4} because 2 is repeated twice.

Öskå
  • 8,587
  • 4
  • 30
  • 49
niren
  • 743
  • 4
  • 13
  • 2
    look here, similar one + sorting: http://mathematica.stackexchange.com/questions/27274/sortunion-on-a-list – Kuba Jun 25 '13 at 09:04
  • @Mr.Wizard Why has my flag counter been reset??? – Artes Jun 25 '13 at 22:08
  • @Artes Now that you mention it, I see that its totally gone from my profile page. – Sjoerd C. de Vries Jun 25 '13 at 22:20
  • Closely related: http://mathematica.stackexchange.com/q/6279/121 – Mr.Wizard Jun 25 '13 at 22:25
  • @SjoerdC.deVries I had seen the same issue before I updated my profile. Now my flag counter shows just 0. So it seems like a global crash of mathematica.stackexchange :). – Artes Jun 25 '13 at 22:32
  • @Artes I have no idea why everyone's flag history went to zero, but it appears to be back now. Please let me know if it happens again. – Mr.Wizard Jun 26 '13 at 07:53
  • 1
    @Artes The flagging system is undergoing some major overhaul (esp. in the backend... not sure how much of it we'd actually see). Some of those involve what flags actually reach the mods and what should be left to the community to decide (e.g. off-topic flags). So such counter resets might occur temporarily as they make changes. Don't worry, they're only temporary caching effects and not permanent (cc @Sjoerd) – rm -rf Jun 26 '13 at 17:44

1 Answers1

7

You can use many functions, but the most straightforward approach uses DeleteDuplicates with a test function:

DeleteDuplicates[ {{1, 3}, {2, 5}, {3, 6}, {2, 4}}, First @ #1 == First @ #2 &]
{{1, 3}, {2, 5}, {3, 6}}
Artes
  • 57,212
  • 12
  • 157
  • 245