4

Arbitrary lists are easy to use with Optional:

a[0]~MatchQ~a[0, Optional[x_List, {}]]
a[0]~MatchQ~a[0, Optional[x:{___}, {}]]

True

True

but

a[0]~MatchQ~a[0, Optional[x:{__}, {}]]

False

However, the following, which is semantically equivalent, works:

a[0]~MatchQ~a[0, Optional[x_List /; Length[x] > 0, {}]]

True

Would you consider this a bug?

masterxilo
  • 5,739
  • 17
  • 39

0 Answers0