expreduce
expreduce copied to clipboard
Order in which rules get applied
The order in which rules get applied is different than in Wolfram Language in two notable cases. I think both of them should be fixed. Mathematica:
{a, b} /. {a -> b, b -> c, c -> d}
(* Out: {b, c} *)
Expreduce:
{a, b} /. {a -> b, b -> c, c -> d}
(* Out: {d, d} *)
When expreduce has applied the first replacement rule it continues to apply the subsequent replacement rules to the replaced parts. Replaced parts should preferably be impervious to subsequent replacement rules.
Then there is this, in Mathematica:
h[f, g] /. {f -> b, h[f, g] -> a}
(* Out: a *)
Note that it tries to replace the expression at the top level first before it moves on to lower levels. This is how I think expreduce should also proceed, level by level. Currently it proceeds rule by rule:
h[f, g] /. {f -> b, h[f, g] -> a}
(* Out: h[b, g] *)
h[f, g] /. {h[f, g] -> a, f -> b}
(* Out: a *)
This issue is related to #37