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

Unified Diff: pkg/polymer_expressions/lib/src/globals.dart

Issue 23874018: add enumerate to the default filter set (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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: pkg/polymer_expressions/lib/src/globals.dart
diff --git a/pkg/polymer_expressions/lib/src/globals.dart b/pkg/polymer_expressions/lib/src/globals.dart
new file mode 100644
index 0000000000000000000000000000000000000000..0133a6ef9f0f7012429a78ae9af5fab52025cb97
--- /dev/null
+++ b/pkg/polymer_expressions/lib/src/globals.dart
@@ -0,0 +1,26 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/**
+ * Contains functions that are included by default in [PolymerExpressions].
+ *
+ * - [enumerate]: a convenient way to iterate over items and the indexes.
+ */
+library polymer_expressions.src.globals;
+
+/**
+ * Returns an [Iterable] of [IndexedValue]s where the nth value holds the nth
+ * element of [iterable] and its index.
+ */
+Iterable<IndexedValue> enumerate(Iterable iterable) {
+ int i = 0;
+ return iterable.map((e) => new IndexedValue(i++, e));
+}
+
+class IndexedValue<V> {
+ final int index;
+ final V value;
+
+ IndexedValue(this.index, this.value);
+}

Powered by Google App Engine
This is Rietveld 408576698