Re: [R] Partial function application in R

2009-03-12 Thread nosek
Sorry for not answering long. After working a lot with new version of "bind" function I find it actually really useful. Just to avoid any possible hard-to-debug errors I try to stick to some good practices, like always specifying default values for formal parameters and calling "bind" with named a

Re: [R] Partial function application in R

2009-01-17 Thread Wacek Kusnierczyk
nosek wrote: > Hello, > > soon after my last posting to this thread I stumbled upon the do.call > function and came to the very much the same version as yours. It is good! > at least for the sort of tasks as in the examples below. but i haven't tested it beyond those, and in r you shouldn't re

Re: [R] Partial function application in R

2009-01-17 Thread nosek
Hello, soon after my last posting to this thread I stumbled upon the do.call function and came to the very much the same version as yours. It is good! However, it looks that both name clashes and mixing keyword and positional styles in argument binding and function calls may lead to very drastic

Re: [R] Partial function application in R

2009-01-15 Thread Wacek Kusnierczyk
czesc, looks like you want some sort of currying, or maybe partial currying, right? anyway, here's a quick guess at how you can modify your bind, and it seems to work, as far as i get your intentions, with the plot example you gave: bind = function(f, ...) { args = list(...) function(...)

Re: [R] Partial function application in R

2009-01-15 Thread Gabor Grothendieck
One other idea. The proto package also does currying. If f a method (i.e. an R function that takes an object as arg1 then p$f, i.e. the $.proto function, returns function(...) f(p, ...). Looking at the code for setDefaults as in my prior response and/or proto should give you some ideas. On Thu,

Re: [R] Partial function application in R

2009-01-15 Thread nosek
Well, it looks like it's a perfectly correct approach to bind functions writing their wrappers by hand. But I don't want to write them by hand every time I need them. Being lambda expression, function() is most general, but there must be some kind of shorter way for such a common task as partial

Re: [R] Partial function application in R

2009-01-15 Thread Gabor Grothendieck
Have a look at the setDefaults package. It will set the default arguments of a function to whatever you specify so that if you omit them then those are the values you get for them. On Thu, Jan 15, 2009 at 4:25 PM, nosek wrote: > > Hello, > > in a desperate desire of using partial function applic

Re: [R] Partial function application in R

2009-01-15 Thread David Winsemius
How is function() not the correct approach? > plot_lines <- function(x, ...) plot(x, type="l", ...) > > plot_lines(1:10, xlim = c(1,5)) > plot_lines(1:10, 11:20, xlim = c(1,5)) Still seems to get the unnamed optional y argument to the plotting machinery. -- David Winsemius On Jan 15, 2009