Thanks, Hadley. This (i.e., different ways to prepare curry) is quite instructive to me.
Best, Ravi. ------------------------------------------------------- Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu -----Original Message----- From: h.wick...@gmail.com [mailto:h.wick...@gmail.com] On Behalf Of Hadley Wickham Sent: Wednesday, May 04, 2011 12:01 PM To: Duncan Murdoch Cc: Ravi Varadhan; Byron Ellis; R Development Mailing List Subject: Re: [Rd] Curry: proposed new functional programming, er, function. >> # Use of Curry >> adaptIntegrate(Curry(f, a=0.2), lower=0, upper=2) > > Two objections: > > 1. I don't see how that is preferable to > > adaptIntegrate(function(x) f(x, a=0.2), lower=0, upper=2) It's less typing? A more helpful use is when you have a list of functions: funs <- list( sum = sum, mean = mean, median = median ) with Curry function you can do : funs2 <- lapply(funs, Curry, na.rm = TRUE) as opposed to funs2 <- list( sum = function(x, ...) sum(x, ..., na.rm = TRUE), mean = function(x, ...) mean(x, ..., na.rm = TRUE), median = function(x, ...) median(x, ..., na.rm = TRUE) ) > 2. There seems to be confusion about what currying means. The Wikipedia > page <http://en.wikipedia.org/wiki/Currying> indicates that the function > Curry() defined above is really doing "partial function application", not > currying. I'm in no position to judge whether Byron got it right or > Wikipedia did, but this suggests to me that the name "Curry" is > inappropriate, since at least some people who know what currying is would > not guess that it does what it does. I'm not completely sure that discussion is canonical: wikipedia citing a blog post does not a precedent make. I agree the distinction is sensible, but I think the partial function application sense of currying is standard enough that it would cause much confusion. We are not claiming that R has low-level currying, we're creating a function to simulate a useful property of currying. Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel