Asp.net programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this Asp.net and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Asp.net Website by URL, How to Play YouTube Videos in Asp.net by using Jquery , Jquery Change div background on mouseover in asp.net , JQuery UI Datepicker (Calendar) etc.

Wednesday, February 22, 2017

How to extract mutually disjoint elements of a list of lists

Extract mutually disjoint elements of a list:

 I have a list of lists, for example:
my_list = {{1,2,9},{2,3,7},{5,6,9},{8,10,11}}




Result is :(Try this ) i got form web 
fn=Module[{ms = Subsets[#, {2, Length@#}]}, 
  Take[Reverse[Pick[ms, And @@ DisjointQ @@@ Subsets[#, {2}] & /@ ms]],
UpTo[1]]] &;

mylist = {{1, 2, 9}, {2, 3, 7}, {5, 6, 9}, {8, 10, 11}}
fn@mylist
my_list = {{1,2,9},{2,3,7},{5,6,9},{8,10,11}}

No comments:

Post a Comment