Currying in Typescript. language level support.

Topics: General
Oct 6, 2012 at 3:23 PM

Hi!

Will the added support a syntax for currying?

Coordinator
Oct 8, 2012 at 3:57 PM

We support currying through the ES5 standard way of currying, as in this example:

var foo: Function = function (a, b) { return a + b; };

var bar = foo.bind(null, 1);

document.writeln(bar(4));
Jun 7, 2014 at 5:23 PM
What about a nicer syntax with placeholders ?
function f(a,b,c) { return a+b+c;}

var g = f(_, 2, 3);  // <-> function g(a) { return f(a, 2, 3) }
g(1);
Mar 14, 2015 at 1:14 PM
That's partial application, not currying. :P
Mar 14, 2015 at 8:35 PM
Indeed.
I didn't say it is currying :)