Hello everyone, I'm newbie. Why in {1, x^1, x^2, x^3} /. x^n_ -> r[n] out {1, x, r[2], r[3]} ? I expected {1, r[1], r[2], r[3]}
Thanks in advance.
Hi,
That is since x^1 is automatically evaluated to x. Compare:
x^1 // FullForm x^n // FullForm
Use HoldForm[] to get what you expect:
HoldForm[{1, x^1, x^2, x^3}] /. x^n_ -> r[n]
I.M.