You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[EDIT] Add class names and existing Zip method for context by @karelz
Reacted by Aluan Haddad, Derek Gray, Unknown6656, Mark Adamson, Erik Schierboom, Meir Blachman, Joseph Musser, Ashley, Rikki Gibson, Rasmus Melchior Jacobsen and 3 more
How would Unzip work when it comes to laziness? Would it be similar to GroupBy, which I belive iterates the whole input before yielding the first result? Or something more lazy, where iterating first would iterate input at the same time, while saving second results to a queue (and vice versa)?
Also, considering that with this change, there would be tuple and non-tuple Zip, but only tuple Unzip, would it make sense to also add "non-tuple" Unzip? The API would be:
Note that we do not offer Seq.unzip functionality, which would be the the analogue to IEnumerable.Unzip. This is because we would need to drop laziness to accomplish the task, thus breaking one of the assumptions people have about working with F# sequences (which are just type aliases for IEnumerable<T>.
I've create a PR (dotnet/corefx#26582) that adds the Zip functionality described in the issue.
One thing that I'm considering but haven't decided upon: would it be OK to return a concrete struct-iterator type instead of IEnumerable? It seems like forcing the IEnumerable overhead is something that many users would prefer not to do.
@VSadov and @OmarTawfik you're listed as experts for System.Linq. What would you like me to do here? Just publish a PR? The Zip API from above is still accurate.
would it be OK to return a concrete struct-iterator type instead of IEnumerable? It seems like forcing the IEnumerable overhead is something that many users would prefer not to do.
For better or worse, returning IEnumerable<T> is the pattern LINQ uses. What makes Zip special? Why should it be different?
How come this didn't make its way into .NET Standard 2.1? Was hit with a compile error when switching a console app (netcoreapp3.0) to a class lib(netstandard2.1). I reverted to the old .Zip(), so just wondering why it didn't make the cut.
How come this didn't make its way into .NET Standard 2.1?
With .NET 5 coming up I guess it is not the most important question to be answered (as I assume 2.1 is the last version?), I am still curious though. @terrajobst
The short answer is timing. Coordinating changes between two ongoing release trains is challenging, especially when things change after merging. Hence, our generally policy for .NET Standard has been that we only standardize what was shipped before. During .NET Standard 2.1, we have relaxed that requirement to ship some of the high-impact features together with .NET Core 3.0.
Reacted by Benjamin Bartels and John Zabroski
ghost locked as resolved and limited conversation to collaborators on Dec 26, 2020
Activity
svick commentedon Feb 9, 2017
How would
Unzipwork when it comes to laziness? Would it be similar toGroupBy, which I belive iterates the whole input before yielding the first result? Or something more lazy, where iteratingfirstwould iterateinputat the same time, while savingsecondresults to a queue (and vice versa)?Also, considering that with this change, there would be tuple and non-tuple
Zip, but only tupleUnzip, would it make sense to also add "non-tuple"Unzip? The API would be:(IEnumerable<T1> first, IEnumerable<T2> second) Unzip<TInput, T1, T2>(this IEnumerable<TInput> input, Func<TInput, (T1, T2)> selector)(It does use tuple, but only for multiple returns, not for the collection itself.)
karelz commentedon Feb 10, 2017
@jcouv please check our issue guide for assigning issues. And API review process.
VSadov commentedon Jan 23, 2018
CC:@agocke
cartermp commentedon Jan 24, 2018
Related info:
Seq.zipfunctions in FSharp.Core: https://github.com/Microsoft/visualfsharp/blob/master/src/fsharp/FSharp.Core/seq.fs#L626List.zipfunctions: https://github.com/Microsoft/visualfsharp/blob/44fa027b308681a1b78a089e44fa1ab35ff77b41/src/fsharp/FSharp.Core/local.fs#L851List.unzipfunctions: https://github.com/Microsoft/visualfsharp/blob/44fa027b308681a1b78a089e44fa1ab35ff77b41/src/fsharp/FSharp.Core/local.fs#L724Array.zipfunctions: https://github.com/Microsoft/visualfsharp/blob/master/src/fsharp/FSharp.Core/array.fs#L816Array.unzipfunctions: https://github.com/Microsoft/visualfsharp/blob/master/src/fsharp/FSharp.Core/array.fs#L863Note that we do not offer
Seq.unzipfunctionality, which would be the the analogue toIEnumerable.Unzip. This is because we would need to drop laziness to accomplish the task, thus breaking one of the assumptions people have about working with F# sequences (which are just type aliases forIEnumerable<T>.agocke commentedon Jan 25, 2018
I've create a PR (dotnet/corefx#26582) that adds the Zip functionality described in the issue.
One thing that I'm considering but haven't decided upon: would it be OK to return a concrete struct-iterator type instead of
IEnumerable? It seems like forcing the IEnumerable overhead is something that many users would prefer not to do.agocke commentedon Jan 25, 2018
Note: I have not implemented Unzip. I don't think that API is nearly as useful and I'd prefer to decide on the new Zip API without it.
agocke commentedon Jan 25, 2018
@VSadov and @OmarTawfik you're listed as experts for System.Linq. What would you like me to do here? Just publish a PR? The Zip API from above is still accurate.
OmarTawfik commentedon Jan 25, 2018
@agocke we will need to prepare the API proposal first:
guide: https://github.com/dotnet/corefx/blob/master/Documentation/project-docs/api-review-process.md
example: https://github.com/dotnet/corefx/issues/14220
Then it will go through a design review, and after approval, you can submit the PR for normal code review process.
svick commentedon Jan 25, 2018
@agocke
For better or worse, returning
IEnumerable<T>is the pattern LINQ uses. What makesZipspecial? Why should it be different?[-]Proposal: Zip and Unzip LINQ APIs [/-][+]Proposal: New Zip LINQ Tuple Overload API[/+]agocke commentedon Feb 14, 2018
@karelz I think this is ready for review. I want to add exactly one IEnumerable API: the overload of Zip`2 that returns an IEnumerable of 2-tuples.
karelz commentedon Feb 14, 2018
@agocke please get agreement with @VSadov @OmarTawfik first - they should mark it ready for review.
OmarTawfik commentedon Feb 16, 2018
@karelz I think this is ready to be reviewed next week.
VSadov commentedon Feb 16, 2018
@karelz - 👍 we should review this.
terrajobst commentedon Apr 24, 2018
Video
❤️
Neme12 commentedon May 19, 2018
Should the result be a named tuple?
(TFirst first, TSecond second)for symmetry with the parameters?agocke commentedon May 19, 2018
@Neme12 We could, although tbh i don't see much difference between "first" and "Item1".
People could give more useful names by saying
IEnumerable<(int key, int value)> zipped = Zip(...)Thaina commentedon Feb 6, 2019
If we would added API for
ZipI would like to haveZipoverload with more than 2 variables tooRyotaMurohoshi commentedon May 11, 2019
This method is added 🎉
Related Issues
https://github.com/dotnet/corefx/issues/24788
Related PullRequests
dotnet/corefx#26582
dotnet/corefx#33709
dotnet/corefx#35595
👍
bbartels commentedon Oct 20, 2019
How come this didn't make its way into .NET Standard 2.1? Was hit with a compile error when switching a console app (netcoreapp3.0) to a class lib(netstandard2.1). I reverted to the old .Zip(), so just wondering why it didn't make the cut.
stephentoub commentedon Oct 20, 2019
@terrajobst?
bbartels commentedon Feb 10, 2020
With .NET 5 coming up I guess it is not the most important question to be answered (as I assume 2.1 is the last version?), I am still curious though. @terrajobst
terrajobst commentedon Feb 10, 2020
The short answer is timing. Coordinating changes between two ongoing release trains is challenging, especially when things change after merging. Hence, our generally policy for .NET Standard has been that we only standardize what was shipped before. During .NET Standard 2.1, we have relaxed that requirement to ship some of the high-impact features together with .NET Core 3.0.