5
$\begingroup$

Can anyone explain why the following pattern matches:

[In1]:MatchQ[Hold[a + c + b], Hold[x_ + b + a]]
[Out1]:True

But this one fails:

[In1]:MatchQ[Hold[c + b + a], Hold[x_ + b + a]]
[Out1]:False

It seems that the pattern matcher tries all permutations even if the Plus expression is held (case 1), so why does it fail for case 2?

Many thanks for your help

$\endgroup$
2
  • 1
    $\begingroup$ related $\endgroup$
    – Lacia
    Feb 15, 2023 at 17:14
  • $\begingroup$ This is an interesting question that seems not to have a simple answer. Maybe you will ask: [email protected] and tell us what they replied. $\endgroup$ Feb 17, 2023 at 16:54

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.