16
I've two IEnumerable<double>s, that I want to build an IEnumerable of Tuple<int, double, double> from. Item1 of the Tuple should be the index of the item, Item2 the value in index-th place in the first collection, and Item3 the value in index-th place in the second collection. Is this something that can be done easily in Linq?
E.g.
var first = new List<double>() { 10.0, 20.0, 30.0 };
var second = new List<double>() { 1.0, 2.0, 3.0 };
var result = TupleBuild(first, second);
// result = {(0, 10.0, 1.0), (1, 20.0, 2.0), (2, 30.0, 3.0)}
where:
IEnumerable<Tuple<int, double, double>> TupleBuild(IEnumerable<double> first, IEnumerable<double> second)
{
// does some funky Linq
}
I realise I could write some longhand code for this, but I'd rather not reinvent the wheel if Linq has this covered.