I am trying to solve the following problem. I have tuples of size 3
{{a, b, c}, {a, b, c}, {a, b, c}}
I would like to find cases where
- all the elements in a tuple are the same
- all the elements in a tuple are different
I can solve the first problem with a named pattern something like
x = {{a, b, c}, {a, a, a}, {a, b, c}}
Cases[x, {i_,i_,i_}]
-> {{a, a, a}}
I am unable to solve the other one. Naive approach like this
x = {{a, b, c}, {a, a, a}, {a, b, c}}
Cases[x, {i_,j_,k_}]
-> {{a, b, c}, {a, a, a}, {a, b, c}}
does not work since i, j, k can be different but also can match the same element.
I am looking for a solution using patterns and rules. I could probably construct some solution based on uniqueness of the set but this is a part of larger problem so I am trying to find some elegant solution and also it serves as an exercise to learn more about patterns.