When I evaluate the following expression,
{a -> "value1", b -> "value22"} /. {Rule[x_, y_] -> Rule[x, y]}
I get {a -> "value1", b -> "value2"}, as expected.
But when I evaluate the same expression with a ToString[] wrapper around a named pattern, it is no longer recognized as a named pattern:
{a -> "value1", b -> "value2"} /. {Rule[x_, y_] -> Rule[x, ToString[y]]}
Result: {a -> y, b -> y}.
Why is y not replaced with the corresponding right-hand side values in replacement rules? How can I fix this?
{a -> "value1", b -> 1} /. Rule[x_, y_] :> Rule[x, ToString[y]]gives you{a -> "value1", b -> "1"}– Dr. belisarius Feb 16 '14 at 23:37:>instead of->fixed the problem. Thanks a bunch! – verse Feb 16 '14 at 23:39RulevsRuleDelayed– Mike Honeychurch Feb 16 '14 at 23:39