Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Currying functions in R

Tags:

Is it possible to use currying in R?

One possibility is to have special paste functions (it can be considered as a follow up to here), e.g. (in incorrect code):

'%+%' <- (sep)function(x,y) paste(x,y,sep=sep) "a"%+%("")"b"%+%("_")"c" #gives "ab_c" 

What would be a possible implementation in R?

PS: The paste is just an example, I am curious about the possibilities of R...

like image 402
teucer Avatar asked Mar 18 '11 15:03

teucer


1 Answers

The standard place for functional programming in R is now the functional library, this library substitutes the ROxigen library that is discussed here :

library(functional) newfunc <- Curry(oldfunc,x=5) 
like image 119
Ari B. Friedman Avatar answered Nov 11 '22 05:11

Ari B. Friedman