higher level functions in R - is there an official compose operator or curry function?

后端 未结 4 1194
春和景丽
春和景丽 2020-12-07 11:05

I can create a compose operator in R:

 `%c%` = function(x,y)function(...)x(y(...)) 

To be used like this:

 > numericNull         


        
4条回答
  •  生来不讨喜
    2020-12-07 11:58

    The standard place for functional programming in R is now the functional library.

    From the library:

    functional: Curry, Compose, and other higher-order functions

    Example:

       library(functional)
       newfunc <- Curry(oldfunc,x=5)
    

    CRAN: https://cran.r-project.org/web/packages/functional/index.html

    PS: This library substitutes the ROxigen library.

提交回复
热议问题