In Wolfram Research Mathematica it is possible to define a sustitution rule of the type
sustitution = g_[arg___] -> g[Sequence @@ Reverse[{arg}]]
Then it is possible to apply it to different expressions involving functions with the following results:
f[x, y] /. sustitution >> f[y,x]
g[x1,x2,x3] >> g[x3,x2,x1]
h[1,z,w,t]/.sustitution >> h[t,w,z,1]
As it is possible to use a pattern with name, g_, for the name of the function and another pattern, arg___, for the arguments, the same sustitution rule is valid no matter the name of the function that appears in the expression.
Is it possible to use WildFunction symbols along with replace to obtain a similar efect with Sympy?
Aucun commentaire:
Enregistrer un commentaire