MathGroup Archive 2006

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

Search the Archive

Re: Or in a Select question


János wrote:
> Hi,
> 
> I have a list
> 
> lst={a,b,c}
> 
> I make another list from it the following way:
> 
> In[2]:=
> pp = Partition[Tuples[lst,
>      2], 2, 1]
> Out[2]=
> {{{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}}}
> 
>  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]] ||
                              ^^
                              ||

Use && instead of || here.

>      #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}}}
> 
[snip]

Carl Woll
Wolfram Research


  • Prev by Date: Re: Plotting Cosh(x)?
  • Next by Date: Formatted Date String
  • Previous by thread: Or in a Select question
  • Next by thread: Re: Or in a Select question