+ 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
13 Respostas
+ 7
https://code.sololearn.com/cojlDyQPy3b5/?ref=app
+ 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
+ 4
That's very clever guys!!
+ 4
~ swim ~ in plain old C it would not be possible to implement it without macros would it?
+ 4
~ swim ~ OK, I missed the non-macro version. Baptiste E. Prunier are you able to separately post the version without macros?
+ 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 ^^
+ 2
Yes combination of 3 language +
JS is possible all as being calculated as 3+1 different sums or problems.
😑
+ 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?