In Linq we can combine two lists with a the Enumerable.Zip method:
public static IEnumerable<TResult> Zip<TFirst, TSecond, TResult>(
this IEnumerable<TFirst> first,
IEnumerable<TSecond> second,
Func<TFirst, TSecond, TResult> resultSelector
)
I would like the equivalent to Zip an arbitrary number of enumerables of the same type. Something with a method signature a bit like this:
public static IEnumerable<TResult> Zip<TIn, TResult>(IEnumerable<IEnumerable<TIn>>inputs, Func<IEnumerable<TIn>, TResult> combiner)
Where the as the enumerable is iterated, it returns an enumerable containing an element from each of the corresponding enumerables.
Does this exist anywhere? Or is it simple to build with existing Linq methods? Aggregate multiple zips?