-
Notifications
You must be signed in to change notification settings - Fork 418
Add ZipMap #763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add ZipMap #763
Conversation
FYI: This operator has been included in SuperLinq 4.0.0, which has now been published. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matachi Thanks for contributing this and sorry for having taken so long to get back with a review. Usually, I don't pay attention to a new PR unless the CI build errors are fixed. Anyway, since master
had moved on considerably since this PR was opened, I've aligned it with a merge and added my review. Hope you'll find the time to address the comments soon.
/// ("foo", false"), ("bar", true) and ("baz", true), in turn. | ||
/// </example> | ||
|
||
public static IEnumerable<(TSource Item, TResult Result)> ZipMap<TSource, TResult>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the first tuple element should be named Source
or Input
instead of Item
. Thoughts?
foreach (var item in source) | ||
{ | ||
yield return (item, func(item)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The NullArgumentTest
tests are breaking. The fix is to validate the arguments eagerly and wrap the iterator in a local function as follows (otherwise arguments are validated when the sequence is iterated rather than when ZipMap
is called):
foreach (var item in source) | |
{ | |
yield return (item, func(item)); | |
} | |
return _(); IEnumerable<(TSource, TResult)> _() | |
{ | |
foreach (var item in source) | |
{ | |
yield return (item, func(item)); | |
} | |
} |
Co-authored-by: Atif Aziz <[email protected]>
Co-authored-by: Atif Aziz <[email protected]>
Co-authored-by: Atif Aziz <[email protected]>
Co-authored-by: Atif Aziz <[email protected]>
Co-authored-by: Atif Aziz <[email protected]>
Co-authored-by: Atif Aziz <[email protected]>
Co-authored-by: Atif Aziz <[email protected]>
Co-authored-by: Atif Aziz <[email protected]>
Co-authored-by: Atif Aziz <[email protected]>
Co-authored-by: Atif Aziz <[email protected]>
Co-authored-by: Atif Aziz <[email protected]>
Implementation of
ZipMap
proposed in #661.