# Construct 1 variable function from given 2 variable function

Given a function f[x , y].
The definition of f is not self-describing. (f was defined with objects other than f.)
Then I want to construct a function g[x] such that
f[x,y] and g[x][y] are the same, and the definition of g does not contain f.

For example, given

In  f[x_, y_] := x^2 + y^3


I've tried

In g[x_]:=f[x,#]&


Checked an example

In  f[3,2] == 17 == g
Out True


Looks okay so far but

In  Definition[g]
Out g[x_] := f[x, #1] &


The definition of g contains f. (fail)
What I want is a function h such that

In Definition[h]
Out x^2+#1^3&


I've tried Evaluate/Activate/FullSimplify, to g, but not worked.

Can you construct a function let's say, ToOperator, such that ToOperator[f] wil produce h ?

(ToOperator produces a warning message if the definition of f is self-describing. The generalization of ToOperator will be of course, multiple variable function as input + user choose some of those variables)

What you want is called "currying".

Not involving new operators you may try:

Clear[f, g]
f[x_, y_] := x^2 + y^3
g[x_] = Evaluate[f[x, #]] &;

f[3, 2] == 17 == g
?? g However, MMA has a special operator CurryApplied for this:

Clear[f, g]
f[x_, y_] := x^2 + y^3
g = CurryApplied[f, 2];
f[3, 2] == 17 == g
?? g You may want to also look at OperatorApplied.

• To quote the OP (re CurryApplied solution): "The definition of g contains f. (fail)". Mar 22 at 14:10