Displaying 1 result from an estimated 1 matches for "325584".
Did you mean:
32584
2010 Aug 05
4
Reducing a list of functions by composition fails
Hi All,
I'd like to be able to specify the ordered composition of several
functions. So I defined compose:
compose <- function(f,g){
function(x){f(g(x))}
}
and some simple test functions:
plus2 <- function(x){x+2}
plus3 <- function(x){x+3}
plus4 <- function(x){x+4}
> (compose(plus2,compose(plus3,plus4)))(3)
[1] 12
Works fine. But trying to reduce a list of functions by