4
$\begingroup$

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?

$\endgroup$
  • $\begingroup$ related: 108636 $\endgroup$ – Kuba Aug 29 '16 at 22:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.