MathGroup Archive 2004

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

Search the Archive

Re: pattern matching and droping elements from list of lists.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg49775] Re: pattern matching and droping elements from list of lists.
  • From: "Dr. Wolfgang Hintze" <weh at snafu.de>
  • Date: Fri, 30 Jul 2004 06:02:27 -0400 (EDT)
  • References: <ceargm$av9$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Define

In[34]:=
li = Outer[List, {a, b, c}, {a, b, c}, {a, b, c}];

Optional simplification of the list

In[36]:=
x = Flatten[li, 2];

Operation yielding what you wanted

In[37]:=
Complement[x, Select[x, Equal @@ #1 & ]]

Out[37]=
{{a, a, b}, {a, a, c}, {a, b, a}, {a, b, b}, {a, b, c},
   {a, c, a}, {a, c, b}, {a, c, c}, {b, a, a}, {b, a, b},
   {b, a, c}, {b, b, a}, {b, b, c}, {b, c, a}, {b, c, b},
   {b, c, c}, {c, a, a}, {c, a, b}, {c, a, c}, {c, b, a},
   {c, b, b}, {c, b, c}, {c, c, a}, {c, c, b}}

Checkinh lengths

In[4]:=
Length[x]
Length[y]

Out[4]=
27

Out[5]=
24

Regards,
Wolfgang

sean kim wrote:

> hello group, 
> 
> Outer[List, {a, b, c}, {a, b, c}, {a, b, c}]
> 
> will output 
> 
> {{
> {{a, a, a}, {a, a, b}, {a, a, c}}, {{a, b, a}, {a, b, b}, {a, b, c}},
> {{a, c, a}, {a, c, b}, {a, c, c}}},
> {{{b, a, a}, {b, a, b}, {b, a, c}}, {{b, b, a}, {b, b, b}, {b, b, c}},
> {{b, c, a}, {b, c, b}, {b, c, c}}},
> {{{c, a, a}, {c, a, b}, {c, a, c}}, {{c, b, a}, {c, b, b}, {c, b, c}},
> {{c, c, a}, {c, c, b}, {c, c, c}}
> }}
> 
> how do I remove {a,a,a} and {b,b,b} and {c,c,c} from above? 
> 
> thanks all in advance for any insights 
> 
> sean
> 
> 


  • Prev by Date: Question on Compile[]
  • Next by Date: Re: pattern matching and droping elements from list of lists.
  • Previous by thread: Re: pattern matching and droping elements from list of lists.
  • Next by thread: Re: pattern matching and droping elements from list of lists.