Re: Or in a Select question

*To*: mathgroup at smc.vnet.net*Subject*: [mg67076] Re: Or in a Select question*From*: "J Siehler" <jsiehler at gmail.com>*Date*: Fri, 9 Jun 2006 01:06:36 -0400 (EDT)*References*: <e68q6i$d0p$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

> From here I would like to select all the elements whose sublists > contain only different elements. So my "logical" selection was: > In[54]:= > Select[pp, > #1[[1,1]] =!= #1[[1,2]] || > #1[[2,1]] =!= #1[[2, > 2]] & ] > Out[54]= > {{{a, a}, {a, b}}, > {{a, b}, {a, c}}, > {{a, c}, {b, a}}, > {{b, a}, {b, b}}, > {{b, b}, {b, c}}, > {{b, c}, {c, a}}, > {{c, a}, {c, b}}, > {{c, b}, {c, c}}} The criterion you've written is, return any element where at least one pair contains two different elements. So {{a,a},{a,b}} is selected because of the {a,b}; {{b,b},{b,c}} is selected because of the {b,c}, stb. Unless I badly misunderstood the question, you just want && instead of || : The first list should have distinct elements AND the second list should have distinct elements. In[24]:= Select[pp,(#1[[1,1]]=!=#1[[1,2]])&&(#1[[2,1]]=!=#1[[2,2]])&] Out[24]= {{{a,b},{a,c}},{{a,c},{b,a}},{{b,c},{c,a}},{{c,a},{c,b}}}