Proper Currying in C#

EDIT: As noted in comments, this is partial application rather than currying. I wrote a blog post on my understanding of the difference, which folks may find interesting. Well, it’s not particularly different – but I’d separate out the currying part from the “calling DoSomething” part: public static Func<TResult> Apply<TResult, TArg> (Func<TArg, TResult> func, TArg … Read more

What’s the difference between multiple parameters lists and multiple parameters per list in Scala?

Strictly speaking, this is not a curried function, but a method with multiple argument lists, although admittedly it looks like a function. As you said, the multiple arguments lists allow the method to be used in the place of a partially applied function. (Sorry for the generally silly examples I use) object NonCurr { def … Read more

Is there a way to do currying in C?

I found a paper by Laurent Dami that discusses currying in C/C++/Objective-C: More Functional Reusability in C/C++/Objective-c with Curried Functions Of interest to how it is implemented in C: Our current implementation uses existing C constructs to add the currying mechanism. This was much easier to do than modifying the compiler, and is sufficient to … Read more

JavaScript curry: what are the practical applications?

Here’s an interesting AND practical use of currying in JavaScript that uses closures: function converter(toUnit, factor, offset, input) { offset = offset || 0; return [((offset + input) * factor).toFixed(2), toUnit].join(” “); } var milesToKm = converter.curry(‘km’, 1.60936, undefined); var poundsToKg = converter.curry(‘kg’, 0.45460, undefined); var farenheitToCelsius = converter.curry(‘degrees C’, 0.5556, -32); milesToKm(10); // returns … Read more