Sdk: Add currying

Created on 10 Oct 2011  路  6Comments  路  Source: dart-lang/sdk

_This issue was originally filed by paulpmill...@gmail.com_


Currying is a well-known (in functional languages) technique of transforming a function that takes multiple arguments (or an n-tuple of arguments) in such a way that it can be called as a chain of functions each with a single argument (partial application).

I propose to add its support into dart. Dart could implement them scala-way to keep both named / optional params and currying:

a = function(params1)(params2)(params3) {
  return params1 + params2 + params3
}

a(5)(6)(7)

area-language closed-not-planned type-enhancement

Most helpful comment

_This comment was originally written by paulp...@gmail.com_


Sorry, why this is WontFix?

All 6 comments

_This comment was originally written by esprehn...@gmail.com_


The Function interface is empty which is silly. It should have a method on it to return a partially applied function just like Function.bind() in JS.

https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind

var addOne = function(a, b) { return a + b }.bind(1); // This should work in Dart

_Removed Type-Defect label._
_Added Type-Enhancement, Area-Language labels._

_This comment was originally written by [email protected]_


_Added Triaged label._

_Added WontFix label._

_This comment was originally written by paulp...@gmail.com_


Sorry, why this is WontFix?

Was this page helpful?
0 / 5 - 0 ratings