Python's zip
function does the following:
a = [1, 2, 3]
b = [6, 7, 8]
zipped = zip(a, b)
result
[[1, 6], [2, 7], [3, 8]]
Python's zip
function does the following:
a = [1, 2, 3]
b = [6, 7, 8]
zipped = zip(a, b)
result
[[1, 6], [2, 7], [3, 8]]
Solution 1:
How about this?
C# 4.0 LINQ'S NEW ZIP OPERATOR
I just have come across the same problem. .NET library does not offer the solution, so I made it by myself. Here is my solution.
The
Pivot
method is made as extension toIEnumerable<IEnumerable<T>>
. It requires all the sequences' elements to be of the same typeT
.Also take a look at Cadenza which has all sorts of nifty utility methods.
Specifically look at the Zip extension methods here: http://gitorious.org/cadenza/cadenza/blobs/master/src/Cadenza/Cadenza.Collections/Enumerable.cs#line1303
Solution 2: Similar to C# 4.0 Zip, but you can use it in C# 3.0