Hello,

in a desperate desire of using partial function application in R I fried out
the following piece of code:

bind <- function( f, ... ) {
  args <- list(...)
  function(...) f( ..., unlist(args) )
}

Its purpose, if not clear, is to return a function with part of its
arguments bound to specific values, so that I can for example create and use
functions like this:
 q1 <- bind( quantile, 0.25 )
 lapply( some_list, q1 )

It's been a lot of work and unfortunately is not perfect. My bind applies
arguments only using positional rule. What I dream of is a function bind2
that would apply keyword arguments, like:
 plot_lines <- bind2( plot, type="l" )
which would return
 function(...) plot( type="l", ... )

How to do this in R?

Regards,
nosek
-- 
View this message in context: 
http://www.nabble.com/Partial-function-application-in-R-tp21487269p21487269.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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-contained, reproducible code.

Reply via email to