/.
can be used to replace variables but how can one replace operators.
For example in a * b
, *
can be replaced by +
or x
or /
etc. Is there some function to achieve this?
For example in |
||||
Perhaps use the full names for the operators:
|
|||
|
So you change the expression's head.
|
||||
|
Just to complement: be careful when your symbols have values already assigned.
|
||||
Fu[a_, b_, o_] := Module[{}, Unevaluated[a + b] /. Plus -> o]; Fu[4, 2, Times]
– belisarius Apr 7 at 20:16