I am trying to find a pattern that matches a list of sequences that share a common form. The sequence form is: 1 followed by zero or more nonzero integers, followed by 0. An example list is:
{1,3,2,0,1,0,1,2,0,1,1,4,0}
The closest thing I've struck on so far is this:
MatchQ[{1, 2, 0, 1, 2, 0}, {PatternSequence[1, s___ /; FreeQ[{s}, 0], 0] ..}]
which yields True
in this case because the sequences are both the same. Is there a way to get the s___
to apply uniquely to each instance in the Repeated
? This would solve the problem. Other suggestions are most welcome.