Chromium Code Reviews

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: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
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++) {

Powered by Google App Engine