Re: pattern matching and droping elements from list of lists.
- To: mathgroup at smc.vnet.net
- Subject: [mg49769] Re: pattern matching and droping elements from list of lists.
- From: "Michael Taktikos" <michael.taktikos at hanse.net>
- Date: Fri, 30 Jul 2004 06:02:21 -0400 (EDT)
- References: <ceargm$av9$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
In this case, since the length of the inner sublists is allways 3,
DeleteCases[Outer[List, {a, b, c}, {a, b, c}, {a, b, c}], {x_, x_, x_}, -1]
works.
Generalization, if you produce outer lists with sublists of other lengths:
then you have to give to the allowed sublists an attribute, i.e.
allowQ[sublist_] := Length[Union[sublist]] > 1
and then extract with the function Select the sublists for which allowQ is
True.
Greetings from Hamburg,
Michael Taktikos
"sean kim" <sean_incali at yahoo.com> schrieb im Newsbeitrag
news:ceargm$av9$1 at smc.vnet.net...
> 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
>