Byron Ellis
2007-Nov-01 19:00 UTC
[Rd] Curry: proposed new functional programming, er, function.
Hi all (especially R-core) I suppose, With the introduction of the new functional programming functions into base I thought I'd ask for a Curry() function. I use a simple one that looks this: Curry = function(FUN,...) { .orig = list(...);function(...) do.call(FUN,c(.orig,list(...))) } This comes in really handy when using say, heatmap(): heatmap(mydata,hclustfun=Curry(hclust,method="average")) or other functions where there are ... arguments, but it's not clear where they should end up. -- Byron Ellis (byron.ellis at gmail.com) "Oook" -- The Librarian
Hadley Wickham
2011-May-04 14:29 UTC
[Rd] Curry: proposed new functional programming, er, function.
I thought I might bring this up again - it now seems like Curry would be a natural fit with Reduce, Filter, Find, Map, Negate and Position. Any chance we might see this in a future version of R? Hadley On Thu, Nov 1, 2007 at 2:00 PM, Byron Ellis <byron.ellis at gmail.com> wrote:> Hi all (especially R-core) I suppose, > > With the introduction of the new functional programming functions into > base I thought I'd ask for a Curry() function. I use a simple one that > looks this: > > Curry = function(FUN,...) { .orig = list(...);function(...) > do.call(FUN,c(.orig,list(...))) } > > This comes in really handy when using say, heatmap(): > > heatmap(mydata,hclustfun=Curry(hclust,method="average")) > > or other functions where there are ... arguments, but it's not clear > where they should end up. > > -- > Byron Ellis (byron.ellis at gmail.com) > "Oook" -- The Librarian > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >-- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/
Sharpie
2011-May-04 17:11 UTC
[Rd] Curry: proposed new functional programming, er, function.
Byron Ellis-2 wrote:> > Hi all (especially R-core) I suppose, > > With the introduction of the new functional programming functions into > base I thought I'd ask for a Curry() function. I use a simple one that > looks this: > > Curry = function(FUN,...) { .orig = list(...);function(...) > do.call(FUN,c(.orig,list(...))) } > > ... > >I would like to see this as well---it is one of the functional programming constructs I really miss in R after playing with languages like Haskell. Currently, the only Curry implementation I know of is in the roxygen package which is kind of a weird dependency to install just for this one function. -Charlie ----- Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://r.789695.n4.nabble.com/Curry-proposed-new-functional-programming-er-function-tp917654p3496226.html Sent from the R devel mailing list archive at Nabble.com.
Gabor Grothendieck
2011-May-04 17:18 UTC
[Rd] Curry: proposed new functional programming, er, function.
On Wed, May 4, 2011 at 1:11 PM, Sharpie <chuck at sharpsteen.net> wrote:> Currently, the only Curry implementation I know of is in the roxygen package > which is kind of a weird dependency to install just for this one function. >Not entirely comparable but the proto package supports currying of proto arguments. For example, p$ls returns an "instantiatedProtoMethod" which is an S3 subclass of "function" that is like the original method but with the first argument filled in:> library(proto) > p <- proto(x = 1) > p$ls()[1] "x" -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com