开发者

Currying functions in R

Is it possible to use currying in R?

One possibility is t开发者_StackOverflow社区o 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...


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)


It is possible to curry in R, and there is a definition in the ROxygen package. See the discussion here

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜