3 ms·
Currying in JavaScript ES6
- bastawhiz 9y agoI don't think any of these examples of "currying" are actually examples of currying.
- grzm 9y agoWould you elaborate why you think so?
- bastawhiz 9y agoYou should be able to curry any arbitrary function with an arbitrary number of arguments. Providing a value for the last argument should return the evaluated result of the curried function. If you're not using a JavaScript function's `.length` property to do currying, it's by definition not currying.
- deleted 9y ago[deleted]
- taylodl 9y agoCurrying is also a means for adapting a function for memoization. I blogged about this a while back: https://taylodl.wordpress.com/2013/11/05/functional-javascript-currying/ https://taylodl.wordpress.com/2013/11/05/functional-javascri...
- FrozenVoid 9y ago//Translated to C #include <stdio.h> #include <stdlib.h> #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("result:%d\n",triple(strtol(argv[1],NULL,10))); }
- deleted 9y ago[deleted]