Bug fixed in 10.1
Consider the following pattern-matching expressions:
MatchQ[{1, 2}, {a_, b_}] (* True *)
MatchQ[{1, 2}, {a_, b_:0}] (* True *)
MatchQ[{1, 2}, {PatternSequence[a_, b_]}] (* True *)
MatchQ[{1, 2}, {PatternSequence[a_, b_:0]}] (* False *)
The last result surprises me. I would have expected it to return True
just like the others. I suspect a bug, but does this behaviour conform to some pattern-matching principle that I have overlooked?
Answer
Fixed in 10.1 (windows)
code
MatchQ[{1, 2}, {a_, b_}]
MatchQ[{1, 2}, {a_, b_: 0}]
MatchQ[{1, 2}, {PatternSequence[a_, b_]}]
MatchQ[{1, 2}, {PatternSequence[a_, b_: 0]}]
Comments
Post a Comment