I looked up currying in Shifrin's book.
He points out that currying can be used for pure functions using nested functions as in the following example:
nestedF = Function[x, Function[y, x + y]]
Out: Function[x, Function[y, x + y]]
add3 = nestedF[3]
Out: Function[y$, 3 + y$]
add3[1]
Out: 4
The & notation does not allow for this type of currying (it seems) since an expression with two variables #1 and #2 needs two arguments (less than two gives an error). I would like to create a new function having only one variable by applying a function with two variables to a single argument. This is achieved in the above example via add3.
I tend to program using pure functions in the & format rather than the Function format, as this is closer to lambda notation. However when I want to create a function of one variable from a function with two variables (by applying it to an argument) it seems the code requires the Function[ ] use as opposed to the & notation. Is there any way though to still use the # notation for this purpose?
Example:
((#1 + #2) &)[3]
results in the error:
Function::slotn: Slot number 2 in #1+#2& cannot be filled from (#1+#2&)[3].
rather than in the single-argument function
((3 + #2)&)
as one might expect from lambda notation.
It seems from Shifrin I may have to live with this. I wanted to double check anyone knows a way around it so one can use standard lambda contraction behaviour while still in "lambda-notation" (i.e. using # arguments).