enumerate<T> function

List<Tuple2<int, T>> enumerate<T>(
  1. List<T> list
)

Implementation

List<Tuple2<int, T>> enumerate<T>(List<T> list) {
  if (list.isEmpty) {
    return [];
  }

  var result = <Tuple2<int, T>>[];

  for (var i = 0; i < list.length; i++) {
    result.add(Tuple2(i, list[i]));
  }

  return result;
}