Is there a way to pipeline program with random-access ranges in C#?

Kagamin spam at here.lot
Tue Mar 20 15:57:16 UTC 2018


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


More information about the Digitalmars-d-learn mailing list