We needn't use Map
and Apply
as in ziyuang's answer. We can make use of PatternSequence
with Repeated
(..)
or RepeatedNull
(...)
instead, e.g.
list = {{a1, b1} -> {x1, y1}, {} -> {x3, y3}, {a2, b2} -> {x1, y2},
{} -> {x6, y6}, {} -> {x5, y5}, {} -> {x0, y0}, {a3, b3} -> {x3, y3},
{a4, b4} -> {x4, y4}};
Now we can test various approaches :
{ MatchQ[ #, { PatternSequence[{___} -> {_, _}] ..}]& @ list,
MatchQ[ #, {({PatternSequence[]} | {_, _} -> {_, _}) ..}]& @ list,
MatchQ[ #, {({PatternSequence[___]} -> {_, _}) ..}]& @ list }
{True, True, True}
The advantage of PatternSequence
is seen when we'd like to deal with more sophisticated cases of pattern matching.