# 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[1]  f[x_, y_] := x^2 + y^3


I've tried

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


Checked an example

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


Looks okay so far but

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


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

In[4] Definition[h]
Out[4] 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[3][2]
?? 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[3][2]
?? 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, 2021 at 14:10