The Zip operator is useful for combining two or more lists of data, where by the elements are matched based on their index.
new[] { 1, 2, 3 } .Zip(new[] { "a", "b", "c" }, (left, right) => new { left, right })
OUTPUT
{ left = 1, right = a }
{ left = 2, right = b }
{ left = 3, right = c }
In my previous post I discussed CombineLatest & my desire for language support. Zip is another operator that would benefit from this treatment.
from a in columnA
zip b in columnB
zip c in columnC
select new{a, b}
Could easily be translated into the appropriate lambda syntax;
columnA.Zip(columnB, (a, b) => new { a, b }).Zip(columnC, (_, c) => new { _.a, _.b, c })
Ideally you would be able to build more complex queries using all three!
from r1 in Request("something")
latest r2 in Request("something else")
zip e1 in r1.Events
zip e2 in r2.Events
select new{ e1, e2 }
Actually it would be really nice (and perhaps scary) if developers had the ability to extend query comprehension syntax.
Maybe in C# 8.0 
Comments