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

Unified Diff: sdk/lib/_collection_dev/list.dart

Issue 13548002: Add Iterable.fold (and Stream.fold) which replace `reduce`. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 8 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
« no previous file with comments | « sdk/lib/_collection_dev/iterable.dart ('k') | sdk/lib/_internal/compiler/implementation/lib/js_array.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_collection_dev/list.dart
diff --git a/sdk/lib/_collection_dev/list.dart b/sdk/lib/_collection_dev/list.dart
index d8fe4f89a7cce1dbe39a086581baa8641e14ea52..1e40785f3a6540ab555979cb6cf7ba87fe7236d6 100644
--- a/sdk/lib/_collection_dev/list.dart
+++ b/sdk/lib/_collection_dev/list.dart
@@ -207,6 +207,10 @@ abstract class ListMixin<E> implements List<E> {
Iterable map(f(E element)) => new MappedListIterable(this, f);
reduce(var initialValue, combine(var previousValue, E element)) {
+ return fold(initialValue, combine);
+ }
+
+ fold(var initialValue, combine(var previousValue, E element)) {
var value = initialValue;
int length = this.length;
for (int i = 0; i < length; i++) {
« no previous file with comments | « sdk/lib/_collection_dev/iterable.dart ('k') | sdk/lib/_internal/compiler/implementation/lib/js_array.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698