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.

Currying in JavaScript ES6

17 pointsby matthbergabout 8 years ago

3 comments

FrozenVoidabout 8 years ago
<p><pre><code> &#x2F;&#x2F;Translated to C #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #define CurriedMultiply(m) multiply(n,m) int multiply(int n,int m){return n*m;} int triple(int n){return CurriedMultiply(3);} int main(int argc,char**argv){ printf(&quot;result:%d\n&quot;,triple(strtol(argv[1],NULL,10))); }</code></pre>
taylodlabout 8 years ago
Currying is also a means for adapting a function for memoization. I blogged about this a while back:<p><a href="https:&#x2F;&#x2F;taylodl.wordpress.com&#x2F;2013&#x2F;11&#x2F;05&#x2F;functional-javascript-currying&#x2F;" rel="nofollow">https:&#x2F;&#x2F;taylodl.wordpress.com&#x2F;2013&#x2F;11&#x2F;05&#x2F;functional-javascri...</a>
bastawhizabout 8 years ago
I don&#x27;t think any of these examples of &quot;currying&quot; are actually examples of currying.
评论 #14373391 未加载
评论 #14372632 未加载