Why BlankNullSequence rest___
is not matched with nothing (empty expression) ?
a^2 /. Times[rest___, x_^2] -> 2
(* a^2 *)
a^2 /. Plus[rest___, x_^2] :> 2
(* a^2 *)
Should not the answer be 2
in both cases ? How should be the pattern for that ?
Power
, and therefore will be ignored. $\endgroup$Power
? Botha^2
andx_^2
have the same headPower
. $\endgroup$