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$
1
  • $\begingroup$ related: 108636 $\endgroup$
    – Kuba
    Aug 29, 2016 at 22:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.