News for hackers. Stuff that matters.
Re:Ruby Currying by raganwald on Monday May 25, 2009 @04:18PM (#625828)
As mentioned elsewhere, is this currying? Or partial application?

Currying:

lambda { |x,y| x + y }.curry => lambda { |x| lambda { |y| x + y } }

Partial Application

lambda { |x, y| x + y }.apply(2) => lambda { |y| 2 + y }

And given #curry, #apply is trivial:

class Proc; def apply(param); self.curry.call(param); end end

...or at least, that's my understanding...

Re:Ruby Currying by grandalf on Monday May 25, 2009 @04:36PM (#625850)
i think you're right.
Re:Ruby Currying by grandalf on Monday May 25, 2009 @04:37PM (#625853)
After learning about these concepts in Haskell, the Ruby code seems downright ugly (I never thought I'd say that)... but still probably quite useful in some cases.
Re:Ruby Currying by khelll on Tuesday May 26, 2009 @04:26AM (#626423)
raganwald, u r totally right, i have updated the post to show the diff.