# MatchQ and patterns for similar lists

I can't seem to find the right set of patterns to independently match two different lists. Simplified versions of the lists are as follows:

list1 = {{2}, {2}, {20}, {2}, {10}}
list2 = {{2}, {2}, {2}, {2}, {2}, {2}}


In general, the second list will always have the same number inside the parentheses. They can have different lengths. Both will have just a single number inside the parentheses.

I am trying to find two patterns (p1,p2):

p1 = {{s_?NumericQ} ..};
p2 = {{_?NumericQ} ..};


Such that

{MatchQ[list1,p1],MatchQ[list1,p2],MatchQ[list2,p1],MatchQ[list2,p2]}


Gives

{True, False, False, True}


My test patterns give {True, True, False, True} instead. I'm sure the answer is easy, but I just can't get it right...

-
I get {False, True, True, True} when I evaluate your code and that is what I would have expected to get. – Mike Honeychurch Apr 18 '12 at 22:26
@MikeHoneychurch sorry must've copied it down wrong! – tkott Apr 18 '12 at 22:28

## 1 Answer

The following patterns give the required output:

p1 = p : {{_?NumericQ} ..} /; ! Equal @@ p
p2 = {{s_?NumericQ} ..};

MatchQ[#[[1]], #[[2]]] & /@ Tuples[{{list1, list2}, {p1, p2}}]

(*
==> {True, False, False, True}
*)

-