Displaying 2 results from an estimated 2 matches for "mogunus".
Did you mean:
magnus
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
2010 Aug 06
3
Partial Function Application
Hi. I would like to partially apply a function to a list of arguments,
and I don't know how to do this in R, without perhaps writing default
values to the formals() of my function, or writing to the environment
object of a function. For context, my definition of partially apply
is: "fix some of the arguments, leaving the others as variables,
return a new function that takes the un-fixed