+ 11

Do languages like C/C++, Java have an equivalent of Currying in Javascript?

The closest thing I can think of is default arguments to methods but it's not the same thing. The following question and it's answers explain currying in js. https://www.sololearn.com/Discuss/1765431/?ref=app

20th Apr 2019, 7:06 AM
Sonic
Sonic - avatar
13 Answers
+ 7
https://code.sololearn.com/cojlDyQPy3b5/?ref=app
21st Apr 2019, 2:33 AM
Hatsy Rei
Hatsy Rei - avatar
+ 5
It is not really beautiful but you can do it in C https://code.sololearn.com/cPFTX2kq1ByL/?ref=app Edit: I added generation macros to at least reduce declaration / definition size
21st Apr 2019, 6:30 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 4
That's very clever guys!!
21st Apr 2019, 7:51 AM
Sonic
Sonic - avatar
+ 4
~ swim ~ in plain old C it would not be possible to implement it without macros would it?
21st Apr 2019, 8:26 AM
Sonic
Sonic - avatar
+ 4
~ swim ~ OK, I missed the non-macro version. Baptiste E. Prunier are you able to separately post the version without macros?
21st Apr 2019, 8:34 AM
Sonic
Sonic - avatar
+ 3
~ swim ~ indeed more readable ! Macros are a double edged sword because they are harder to read, to maintain and to update, but they are really powerful The while is only needed so that the user can go outside the block (with a break) while not leaving the function so that the wrapper is still returned A special return macro could be made instead, with quite the same impact I think. I do not really know which one would be cleaner and more user friendly Sonic I added the first version in a comment so that you can check it, but swim rewrote it before I could do it ^^
21st Apr 2019, 1:04 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 2
Yes combination of 3 language + JS is possible all as being calculated as 3+1 different sums or problems. 😑
21st Apr 2019, 3:18 PM
Asim Farheen
Asim Farheen - avatar
+ 1
Can somebody explain what currying is? Google just confused me. Lol Edit: From what I googled, it's a function that runs a nested function depending on the argument, correct me if I'm wrong. but like argument type or argument value?
21st Apr 2019, 2:22 PM
Daniel Cooper