MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: removing sublist . Again and Different

  • To: mathgroup at smc.vnet.net
  • Subject: [mg56327] Re: removing sublist . Again and Different
  • From: Peter Pein <petsie at arcor.de>
  • Date: Fri, 22 Apr 2005 06:22:56 -0400 (EDT)
  • References: <d47tgv$575$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

giampi1960 wrote:
> hello i read borges2003xx at yahoo.it meassage :
> 
> 
> 
>>i'm a newbie. How implement the _faster functon_ which removes in a
>>list every element that are a subelement.
>>which means
>>f[x]:=  {..,{1,2,3,4},..,{2,3},..} removes {2,3}.
>>thanx a lot.
>>giorgio borghi
> 
> 
> 
> i ask your help for faster way to do the opposite
> f[x]:=  {..,{1,2,3,4},..,{2,3},..} removes {1,2,3,4}.
> 
> best regards
> 
> giampiero
> 

remSupersets[ls_] :=
  Cases[Transpose[{ls,
    Not /@ Or @@@ Table[
      If[i == j, False, Complement[ls[[j]], ls[[i]]] == {}],
     {i, Length[ls]}, {j, Length[ls]}]
    }], {x_, True} :> x]
lst = {{1, 4, 2}, {1, 2}, {1, 2, 3, 4}, {4, 4}, {2, 3}, {1, 2, 3}};

remSupersets[lst]
--> {{1, 2}, {4, 4}, {2, 3}}
-- 
Peter Pein
Berlin


  • Prev by Date: Re: Sort problem
  • Next by Date: Re: Re: (x-y) DiracDelta[x-y] does not simplify to 0
  • Previous by thread: Re: removing sublist . Again and Different
  • Next by thread: Re: removing sublist . Again and Different