Consider a function that sorts its arguments based on a function called order
Clear[f, order]
f[x_, y_] /; order[x] > order[y] := f[y, x]
order[1] = 1;
order[2] = 2;
expr1 = f[1, 2]
expr2 = f[2, 1]
(* f[1, 2] *)
(* f[1, 2] *)
However, let's imagine that we change the ordering function
order[1] = 2;
order[2] = 1;
Surprisingly, expr1
and expr2
still evaluate to f[1,2]
expr1
expr2
(* f[1, 2] *)
(* f[1, 2] *)
However, if we introduce f[1, 2]
we obtain the correct result
f[1, 2]
(* f[2, 1] *)
Is there a way to force the reevaluation of expr
to obtain f[2, 1]
? I am looking for a function along the lines of
ForceEvaluation@expr1
ForceEvaluation@expr2
(* f[2, 1] *)
(* f[2, 1] *)