Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Unified Diff: corelib/src/implementation/collections.dart

Issue 10832060: Add reduce to Collection. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: corelib/src/implementation/collections.dart
diff --git a/corelib/src/implementation/collections.dart b/corelib/src/implementation/collections.dart
index 462d33af2a703382ecf34f320b5b8d8ca1a0913a..9ea332443653b5ec10979bd35fa72c5b15b0bf51 100644
--- a/corelib/src/implementation/collections.dart
+++ b/corelib/src/implementation/collections.dart
@@ -35,6 +35,13 @@ class Collections {
return destination;
}
+ static reduce(Iterable iterable, var init, f(prev, element)) {
Lasse Reichstein Nielsen 2012/08/08 07:19:14 Add return value, even if it's just Object. It dif
Anders Johnsen 2012/08/08 07:56:14 Adding var does not provide any further informatio
Lasse Reichstein Nielsen 2012/08/10 11:26:56 Accepted, but not liked. I prefer being explicit a
+ for (final e in iterable) {
Lasse Reichstein Nielsen 2012/08/08 07:19:14 Yes, that means using 'element' instead of 'e'. It
Anders Johnsen 2012/08/08 07:56:14 It's using the style from the rest of the file/lib
Lasse Reichstein Nielsen 2012/08/10 11:26:56 We do. We shoud. Please start here :)
Anders Johnsen 2012/11/12 12:02:56 Done.
+ init = f(init, e);
+ }
+ return init;
+ }
+
static List filter(Iterable source, List destination, bool f(o)) {
for (final e in source) {
if (f(e)) destination.add(e);

Powered by Google App Engine
This is Rietveld 408576698