On Tuesday, 20 March 2018 at 15:06:14 UTC, Dukc wrote:
Won't quite do it, because that would not iterate backwards.
Linq has no chunking, so you would need to write it, maybe
similar to SelectMany, but with the opposite meaning.
public static IEnumerable<Sequence<T, int>> Enumerate<T>(this
IEnumerable<T> range)
{ return range.Zip(Enumerable.Range(0, int.MaxValue), (x, y)
=> new Sequence<T, int>(x, y));
}
If you want to have index, there's
https://msdn.microsoft.com/en-us/library/bb534869(v=vs.110).aspx