Closed jpotterm closed 10 years ago
Actually, after thinking about this a little more, the best of both worlds would probably be to keep fn.concat
as it is and just add another function, something like:
fn.flatten = fn.partial(fn.apply, fn.concat);
I'll close this, and submit a pull request with the above function.
It may be worth creating a check early on in concat that checks for the proposed syntax (arguments[0] instanceof Array) and then performs a flatten internally
I was wondering if you'd consider changing the signature of the concat method to take an array of arrays which would match Haskell and Underscore.js. The way I see it, concat has two use cases: concatenating individual arrays, and concatenating an array of arrays.
For concatenating individual arrays the current way vs. proposed way would not be much of a change:
But concatenating an array of arrays would be much simpler and more readable:
It would also be mappable without a partial application:
If you'd be willing to accept this change, I can submit a pull request.