Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Ruby Currying (khelll.com)
10 points by batasrki on May 25, 2009 | hide | past | favorite | 4 comments


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...


i think you're right.


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.


raganwald, u r totally right, i have updated the post to show the diff.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: