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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 /**
6 * Contains functions that are included by default in [PolymerExpressions].
7 *
8 * - [enumerate]: a convenient way to iterate over items and the indexes.
9 */
10 library polymer_expressions.src.globals;
11
12 /**
13 * Returns an [Iterable] of [IndexedValue]s where the nth value holds the nth
14 * element of [iterable] and its index.
15 */
16 Iterable<IndexedValue> enumerate(Iterable iterable) {
17 int i = 0;
18 return iterable.map((e) => new IndexedValue(i++, e));
19 }
20
21 class IndexedValue<V> {
22 final int index;
23 final V value;
24
25 IndexedValue(this.index, this.value);
26 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698