From ggrothendieck @ending from gm@il@com  Sun Sep 23 15:23:52 2018
From: ggrothendieck @ending from gm@il@com (Gabor Grothendieck)
Date: Sun, 23 Sep 2018 09:23:52 -0400
Subject: [Rd] Recall
Message-ID: <CAP01uRm5Cuu0RgU_BznfrUHmQLRz9re92ND6uqeR+8vaP8pN3Q@mail.gmail.com>

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



[Rd] Recall
Gabor Grothendieck