On Thursday 18 May 2006 10:27 am, Berger, Daniel wrote: > import functional > > def multiply(x, y): > return x * y > > multiply_by_3 = functional.partial(multiply, 3) > > multiply_by_3(4) #=> Will return 12 > > I understand what it's doing, I just don't understand what purpose of > partial functions would be. an someone provide a use case for me? Hey, I believe this is just a use of currying, a way of reducing the number of arguments to a function by ferreting some of them away (the boring ones). I'll give you a simple example (from last week): # Warning, Scheme! # .. bind zip here .. (binary-search index (lambda (s) (string-compare zip (car s)))) # ... BINARY-SEARCH expects two arguments, an index and a function that takes _one_ argument. Well, I've got to compare two arguments. Thankfully, I'm always comparing against the same zip, so I may as well "curry" it (and store it in the function), and create a new one-argument function on the fly. I'll pass that new function (from the LAMBDA) to BINARY-SEARCH and it'll never know the difference. More on currying here (and it's even not Scheme): http://moonbase.rydia.net/mental/blog/programming/currying-in-ruby.html http://en.wikipedia.org/wiki/Currying The Ruby library Murray was made for currying: http://rubymurray.rubyforge.org/ HTH, Keith