[Rd] Recall
Gabor Grothendieck
ggrothendieck @ending from gm@il@com
Sun Sep 23 15:23:52 CEST 2018
This works:
my.compose <- function(f, ...) {
if (missing(f)) identity
else function(x) f(my.compose(...)(x))
}
my.compose(sin, cos, tan)(pi/4)
## [1] 0.5143953
sin(cos(tan(pi/4)))
## [1] 0.5143953
But replacing my.compose with Recall in the else causes it to fail:
my.compose2 <- function(f, ...) {
if (missing(f)) identity
else function(x) f(Recall(...)(x))
}
my.compose2(sin, cos, tan)(pi/4)
## Error in my.compose2(sin, cos, tan)(pi/4) : unused argument (tan)
Seems like a bug in R.
This is taken from:
https://stackoverflow.com/questions/52463170/a-recursive-compose-function-in-r
--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com
More information about the R-devel
mailing list