TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ruby Currying

10 点作者 batasrki将近 16 年前

3 条评论

raganwald将近 16 年前
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 未加载
grandalf将近 16 年前
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.
khelll将近 16 年前
raganwald, u r totally right, i have updated the post to show the diff.