Hi,
Given this data:
good = {{{"foo"}, {0, 1, 0, 0}}};
bad1 = {{{"foo"}, {0, 0, 0, 0}}};
bad2 = {{{"foo"}, {0, "foo", 0, 0}}};
I want the test to evaluate to True if the numeric list contains only numbers, but not all zeros. This gets me halfway there by catching the bad string:
In[151]:= Table[If[MatchQ[i, {{_, {_?NumberQ ..}} ..}], "pass", "fail"],
{i, {good, bad1, bad2}}]
Out[151]= {"pass", "pass", "fail"}
but adding Except to catch the repeated 0 cases doesn't seem to work like I thought it might:
In[154]:= Table[If[MatchQ[i, {{_, {Except[0, _?NumberQ] ..}} ..}],
"pass", "fail"], {i, {good, bad1, bad2}}]
Out[154]= {"fail", "fail", "fail"}
I've played around with some other patterns, but haven't got it just right. Other approaches?
Thanks,
Josh