Skip to content

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

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open

Add ZipMap #763

wants to merge 15 commits into from

Conversation

DanOpcode
Copy link

Implementation of ZipMap proposed in #661.

@viceroypenguin
Copy link
Contributor

FYI: This operator has been included in SuperLinq 4.0.0, which has now been published.

Copy link
Member

@atifaziz atifaziz left a 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>(
Copy link
Member

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?

Comment on lines +55 to +58
foreach (var item in source)
{
yield return (item, func(item));
}
Copy link
Member

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):

Suggested change
foreach (var item in source)
{
yield return (item, func(item));
}
return _(); IEnumerable<(TSource, TResult)> _()
{
foreach (var item in source)
{
yield return (item, func(item));
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants