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...
{False, True, True, True}
when I evaluate your code and that is what I would have expected to get. $\endgroup$