Skip to content

Instantly share code, notes, and snippets.

@natbusa
Created December 2, 2013 10:52
Show Gist options
  • Save natbusa/7747871 to your computer and use it in GitHub Desktop.
Save natbusa/7747871 to your computer and use it in GitHub Desktop.
currying in R
#function
myfunc.x.a.b.c = function(x,a,b,c) {
a*x*x+ b*x +c
}
myfunc.x.a.b.c(1,2,3,4)
myfunc.x.a.b = function(x,a,b){
function(c) {myfunc.x.a.b.c(x,a,b,c)}
}
myfunc.x.a.b(1,2,3)(4)
myfunc.x.a = function(x,a){
function(b) {myfunc.x.a.b(x,a,b)}
}
myfunc.x.a(1,2)(3)(4)
myfunc.x = function(x){
function(a) {myfunc.x.a(x,a)}
}
myfunc.x(1)(2)(3)(4)
@evertonw
Copy link

evertonw commented Dec 8, 2014

Ok, what is the advantage?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment