-
-
Save fernandojunior/894f231fac9f2aaab79ae5686dfad55b to your computer and use it in GitHub Desktop.
Finally a proper lambda for R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
`<-` = function (body, params) { | |
vars = all.vars(substitute(params)) | |
formals = as.pairlist(setNames(replicate(length(vars), quote(expr = )), vars)) | |
eval.parent(call('function', formals, substitute(body))) | |
} | |
sapply(1 : 4, x -> 2 * x) | |
# 2 4 6 8 | |
mapply(x ~ y -> x + y, | |
seq(1, 5), seq(10, 50, by = 10)) | |
# 11 22 33 44 55 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment