In general, no, f[x][y]
is not the same as f[x, y]
. However, several built-in functions have a similar behavior. For example, myList[[1]][[3]]
is the same as myList[[1, 3]]
, and SortBy[f]
is an "operator form" of SortBy[exp, f]
that can be used as SoryBy[f][myList]
.
The technical term for f[x]=exp
is DownValue
, and the technical term for f[x][y]=exp
is SubValue
. Here is a simple example to show they are different in general:
In[1]:= f[1]="This is a DownValue";
In[2]:= f[2][3]="This is a SubValue.";
In[3]:= f[4][5][6]="Also a SubValue.";
In[4]:= {DownValues[f], SubValues[f]}
Out[4]= {{HoldPattern[f[1]] :> This is a DownValue},
{HoldPattern[f[2][3]] :> This is a SubValue.,
HoldPattern[f[4][5][6]] :> Also a SubValue.}}
You can transform a function of n
arguments f[a, b, c, d, ...]
into a function that can be applied to each argument one at a time as g[a][b][c][d]...
by using Curry
. As an example, you could use Curry
to compute Fourier coefficients like this:
In[1]:= a[f_,n_, min_, max_]:= 1/\[Pi] Integrate[f[x]*Cos[ n*x], {x, min, max}]
In[2]:= coeff = Curry[a, {4, 3, 1, 2}][-\[Pi]][\[Pi]]; (* Some textbooks use 0 to 2Pi, but we use -Pi to Pi. *)
In[3]:= coeff[1, Exp] //InputForm
Out[3]//InputForm= -(Sinh[Pi]/Pi)
In[4]:= 2 Re[FourierCoefficient[Exp[t], t, 1]] // InputForm (* Check our work with Mathematica. *)
Out[4]//InputForm= -(Sinh[Pi]/Pi)
Notice that I have adjusted the order in which the arguments need to be supplied by giving Curry
the argument order as a list {4, 3, 1, 2}
.