Currying: Difference between revisions
Content added Content deleted
No edit summary |
(added Mathematica imkplementation) |
||
Line 259:
(funcall (curry #'+/2 10) 10)
</lang>
=={{header|Mathematica}}==
Currying can be implemented by nesting the <code>Function</code> [[Mathematica]] keyword. The following method curries the <code>Plus</code> function.
In[1]:= plusFC = Function[{x},Function[{y},Plus[x,y]]];
A higher currying function can be implemented straightforwardly.
In[2]:= curry = Function[{x}, Function[{y}, Function[{z}, x[y, z]]]];
Output:
In[3]:= Plus[2,3]
Out[3]:= 5
In[4]:= plusFC[2][3]
Out[4]:= 5
In[5]:= curry[Plus][2][3]
Out[5]:= 5
=={{header|ML}}==
|