[Rd] Recall

Gabor Grothendieck ggrothendieck @ending from gm@il@com
Sun Sep 23 19:06:01 CEST 2018


Please ignore. Looking at this again I realize the problem is that
Recall is not direclty within my.compose2 but rather is within the
anonymous function in the else.
On Sun, Sep 23, 2018 at 9:23 AM Gabor Grothendieck
<ggrothendieck using gmail.com> wrote:
>
> 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



-- 
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