I want to create a rule as a function of z
from a left and right hand side. My (non-working) code and usage is:
toRule[l_, r_] := l[x_] -> r
toRule[f, a+b]
I want the output to be:
(* => f[x_] -> a + b*)
However: when I do this with the code above I get:
(* => f[x$_] -> a + b*)
Where is the $ coming from, and how can I get rid of it?
toRule[l_, r_] := l[x_] -> #&@ r
$\endgroup$toRule[l_, r_] := Rule @@ {l[x_], r}
ortoRule[l_, r_] := Identity[Rule][l[x_], r]
, and everything is dandy. But, often such cases are a signal to reconsider what is it you are actually trying to do - the real need for such tricks is rare. $\endgroup$