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

Unified Diff: runtime/lib/array.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: runtime/lib/array.dart
diff --git a/runtime/lib/array.dart b/runtime/lib/array.dart
index 9980d5da6ff4edbf18a0b52a7de3afc0ead7cf5e..fe4a2748ffa72c0899cfb856f3e89b844a0aedb8 100644
--- a/runtime/lib/array.dart
+++ b/runtime/lib/array.dart
@@ -88,6 +88,10 @@ class ObjectArray<E> implements List<E> {
return Collections.map(this, new GrowableObjectArray.withCapacity(length), f);
}
+ reduce(var init, f(var prev, E element)) {
+ return Collections.reduce(this, init, f);
Lasse Reichstein Nielsen 2012/08/08 07:19:14 Same.
Anders Johnsen 2012/08/08 07:56:14 Done / see other comments.
+ }
+
Collection<E> filter(bool f(E element)) {
return Collections.filter(this, new GrowableObjectArray<E>(), f);
}
@@ -220,6 +224,10 @@ class ImmutableArray<E> implements List<E> {
return Collections.map(this, new GrowableObjectArray.withCapacity(length), f);
}
+ reduce(var init, f(var prev, E element)) {
+ return Collections.reduce(this, init, f);
+ }
+
Collection<E> filter(bool f(E element)) {
return Collections.filter(this, new GrowableObjectArray<E>(), f);
}

Powered by Google App Engine
This is Rietveld 408576698