Re: [R] inverse currying

2009-10-02 Thread baptiste auguie
After some more digging (grep "alist" R-devel/ ), I've come up with this, tools:::as.alist.symbol("x") sugar = function(fun, id = "id"){ ff <- formals(fun) if( id %in% names(ff)) stop(paste(id, "is part of args(fun)")) new.arg <- tools:::as.alist.symbol(id) formals(fun) <- c(unlist(ff),

[R] inverse currying

2009-10-01 Thread baptiste auguie
Dear list, I have the following function, sugar = function(fun, id = "id"){ ff <- formals(fun) if( id %in% names(ff)) stop("id is part of args(fun)") formals(fun) <- c(unlist(ff), alist(id=)) fun } which one may use on a function foo, foo = function(x){ x } sugar(foo) # results i