JuliaLang/julia — Issue #554: Currying?
Author: rtzui
Created: 2012-03-09 15:02:10+00:00
State: open

I idea is relative simple, most languages lack it, but it's awesome and easy to be integrated i guess.. This example is obvious:
`((x,y) -> x + y)(1,2)`
When calling with only one parameter as `((x,y) -> x + y)(1,2)` it raises a wrong number of arguments error. When a function is called with too few arguments it should instead return a anonymous function expecting the a missing one and executing it. So `((x,y) -> x +y)(1)` should return ` (a -> ((x,y) -> x +y)(1,a)) )` (x,y) -> x +y is simply +(x,y). So +(1) would become (a -> +(1,a)). This function increments. Incrementing all fields of an array would be `map(+(1),[1,2,3,4]). ` Of course it would be possible to simply create an anonymous function that increments, but In some cases this would allow a interesting programming style:

```
# could become a library function.
function >>=(a,b)
if a
b(a)
end
end

function reportError(category::String, message::String)
# write errors to different files, maybe send emails.
end

# so some stuff that might fail
data=f(data)

>>=(checkData(data),reportError("serve"))
```