8000 Zip while by Orace · Pull Request #640 · morelinq/MoreLINQ · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Zip while #640

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

Closed
wants to merge 10 commits into from
Closed

Zip while #640

wants to merge 10 commits into from

Conversation

Orace
Copy link
Contributor
@Orace Orace commented Nov 5, 2019

Depend on #639

ZipWhile allow the user to made custom length Zip.

An example of use is when the user wants to create a zip from a main sequence and a secondary sequence and expect the result to be the length of the main sequence regardless of the length of the secondary sequence.

  // continue zip until first source (users) is consumed
  var usersAndEmail = users.ZipWhile(emails, liveSources => liveSources.Contains(1));

If the secondary sequence is longest that the main sequence, the enumeration of the secondary sequence does not reach end.
If the secondary sequence is shortest that the main sequence, the default value is used for padding.

Orace added 10 commits November 4, 2019 17:57
- introduce CustomZip with separate behavior by source
- use CustomZip for EquiZip, ZipLongest and ZipShortest
- add ValueTuple overloads
- use t4 file to have up to 8 input sequences.
@Orace
Copy link
Contributor Author
Orace commented Nov 5, 2019

I would like to avoid the 1-based status access.
My first thought about the predicate was something like that:

  var usersAndEmail = users.ZipWhile(emails, aliveSources => aliveSources .Contains(users));

But I get a warning on users in Contains(users) because it's used while it may have been disposed.

An other option is to expose an object with as many status property as they are enumerable.

  var usersAndEmail = users.ZipWhile(emails, status => status.IsSource1Alive);
  var usersAndEmail = users.ZipWhile(emails, status => status.HasSource1Data);
  var usersAndEmail = users.ZipWhile(emails, status => !status.IsSource1Consumed);

I'm open for propositions here.

@atifaziz
Copy link
Member
atifaziz commented Nov 5, 2019

I don't have enough of the context of your problem to make a call here but something tells me that this is something for Rx and observables (reactive sources), not sequences (interactive sources).

@atifaziz
Copy link
Member

I'm closing this since there's been no follow-up to provide additional context, but reconsider if there's renewed interest to continue the conversation on motivation for this.

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

Successfully merging this pull request may close these issues.

2 participants
0