Re: [R] Partial Function Application

2010-08-06 Thread Mog
Thank you! That's exactly what I wanted. --Mog __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-cont

[R] Partial Function Application

2010-08-06 Thread Mog
e copying the function to several different places with the above methods. Alternately, I could hard-code the partial applications using a function() form, but I would prefer not to do this, as there will be a sizable number of these closures needed and I'd prefer to automat

Re: [R] Reducing a list of functions by composition fails

2010-08-05 Thread Mog
Thanks very much! Works fine now. I'll read up on R's evaluation model. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented,

Re: [R] Reducing a list of functions by composition fails

2010-08-05 Thread Mog
I realize that the Funcall example with an init parameter will work, but I'd like to be able to get a one-argument function/closure out of that reduction, if at all possible. Sorry, I under-specified in my question. Thanks! __ R-help@r-project.org maili

[R] Reducing a list of functions by composition fails

2010-08-05 Thread Mog
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(