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

• To: mathgroup at smc.vnet.net
• Subject: [mg49744] Re: pattern matching and droping elements from list of lists.
• From: "Curt Fischer" <crf3 at po.cwru.edu>
• Date: Fri, 30 Jul 2004 06:01:58 -0400 (EDT)
• References: <ceargm\$av9\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```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

Here's one way.  I'm not sure how efficient it is.

In[1]:=
listOfLists=Outer[List,{a,b,c},{a,b,c},{a,b,c}]

Out[1]=
{{{{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}}}}

In[2]:=
listOfLists/.{y___List,{x_,x_,x_},z___List} -> {y,z}

Out[2]=
{{{{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}}}}

```

• Prev by Date: Re: pattern matching and droping elements from list of lists.
• Next by Date: Re: ListDensityPlot, ColorFunction, and associated confusions
• Previous by thread: Re: pattern matching and droping elements from list of lists.
• Next by thread: Wolfram Technology Conference 2004: Call for Submissions