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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Show HN: Omg-Curry – JavaScript currying library

11 点作者 debdut将近 5 年前

6 条评论

ufo将近 5 年前
I had mixed results in the past when I tried to use currying in Javascript. The stack traces were cluttered by references to the currying function and it also masked bugs if you forgot to pass an argument. Without currying, if you pass less arguments than the function expects then you usually get an error right away complaining that the argument is undefined. However, if the function is curried then it silently succeeds. You only notice the problem later, when you try to use the return value and realize that it is actually a function. To make things worse, when this happens the stack trace points to the place that is trying to use the return value instead of pointing to the function call that is the actual source of the problem.<p>My final impression was that currying works better a language like Haskell that has a strong type system. In a dynamic language it is more problematic.
评论 #24117826 未加载
brundolf将近 5 年前
JavaScript actually has a pretty ergonomic way of doing currying natively:<p><pre><code> const add = (a) =&gt; (b) =&gt; a + b; [1, 2, 3, 4].map(add(2)); &#x2F;&#x2F; [3, 4, 5, 6]</code></pre>
评论 #24115100 未加载
gitgud将近 5 年前
Sorry I&#x27;m not that familiar with this. What would be a good use-case for currying?<p>The example doesn&#x27;t feel that exciting...<p><pre><code> add4(1)(3)(5)(10) add4(1)(3,5)(10) add4(1,3,5,10) &#x2F;&#x2F; 19</code></pre>
评论 #24116871 未加载
评论 #24117319 未加载
评论 #24115352 未加载
giancarlostoro将近 5 年前
&gt; WTF is Curry?<p>&gt; A Curry takes arguments one by one unlike functions which takes all arguments at once.<p>Took the words right out of my brain.
finnh将近 5 年前
The old &quot;drop a link&quot; routine isn&#x27;t beloved here at HN, but this xkcd is just so good:<p><a href="https:&#x2F;&#x2F;xkcd.com&#x2F;2210&#x2F;" rel="nofollow">https:&#x2F;&#x2F;xkcd.com&#x2F;2210&#x2F;</a>
randompwd将近 5 年前
funny how most react devs were using currying directly when they were calling redux lib.<p>still think it(redux) was a misplaced usage of currying.