2
$\begingroup$

Could you please describe the behavior of this code:

p[d[1, 2], d[1, 2]] /. p[a___, Plus[b_], c___] -> {{a}, {b}, {c}}

{{}, {d[1, 2]}, {d[1, 2]}}

Why this pattern matches Plus when the expression doesn't have any Plus functions?

Also, how can I check that all arguments of function p[] don't have any Plus, Times and Power?

$\endgroup$
2
  • 1
    $\begingroup$ Take a look at p[a___, Plus[b_], c___] alone $\endgroup$
    – Kuba
    Commented Nov 10, 2017 at 22:14
  • $\begingroup$ And then after that, look into HoldPattern $\endgroup$
    – QuantumDot
    Commented Nov 11, 2017 at 4:42

0

Browse other questions tagged or ask your own question.