I am trying to write a Mathematica function that will take a rule such as a->b to `b->a'. Can this be done?
a->b
Reverse@Rule[a, b]
Use a pattern to deconstruct the Rule, and reconstitute it backwards in your function body.
Rule
f[Rule[a_, b_]] := Rule[b, a]
a -> b // Reverse
Or
(a -> b)[[{2, 1}]]
a -> b /. (x_ -> y_) -> y -> x
Reverse@Rule[a, b]– Artes Jul 03 '17 at 22:29