TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ruby Currying

10 pointsby batasrkialmost 16 years ago

3 comments

raganwaldalmost 16 years ago
As mentioned elsewhere, is this currying? Or partial application?<p>Currying:<p>lambda { |x,y| x + y }.curry =&#62; lambda { |x| lambda { |y| x + y } }<p>Partial Application<p>lambda { |x, y| x + y }.apply(2) =&#62; lambda { |y| 2 + y }<p>And given #curry, #apply is trivial:<p>class Proc; def apply(param); self.curry.call(param); end end<p>...or at least, that's <i>my</i> understanding...
评论 #625850 未加载
grandalfalmost 16 years ago
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.
khelllalmost 16 years ago
raganwald, u r totally right, i have updated the post to show the diff.