I guess I've been using the Postfix
notation //
wrongly for some time now. I assumed it was a quick way to apply a function to all that precedes it. Now I was surprised by the fact that for example
a // f /. a -> 1
outputs
f[a]
I would have expected this to either be the same as (a // f) /. a ->1
, or as applying the replacement rule first and then the function (a /. a -> 1) // f
. However, both would output f[1]
.
Examining a // f
with FullForm
(and Hold
) does not give me any insight to what is happening either.
The Postfix
documentation is unfortunately very limited. This seems rather trivial, so sorry if this has been asked before, but I couldn't find any post about this.
FullForm[Hold[a // f /. a -> 1]]
, it should help (in general) understanding the order of operations Mathematica invokes. $\endgroup$