Skip to content
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

[Proposal] EquiInterleave #695

Closed
Orace opened this issue Nov 13, 2019 · 2 comments
Closed

[Proposal] EquiInterleave #695

Orace opened this issue Nov 13, 2019 · 2 comments

Comments

@Orace
Copy link
Contributor

Orace commented Nov 13, 2019

Like EquiZip, EquiInterleave throw if input sequences differ in size.

@Orace
Copy link
Contributor Author

Orace commented Nov 13, 2019

What does {1, 2}.EquiInterleave({3}) should yield ?

  • 1, 3, 2, exception
  • 1, 3, exception

@atifaziz
Copy link
Member

This can be achieved relatively easily with EquiZip + SelectMany:

var xs =
    from e in Enumerable.Range(1, 10)
                        .EquiZip(Enumerable.Range(11, 10), ValueTuple.Create)
    from x in MoreEnumerable.Return(e.Item1)
                            .Append(e.Item2)
    select x;

foreach (var x in xs)
    Console.WriteLine(x);

Outputs:

1
11
2
12
3
13
4
14
5
15
6
16
7
17
8
18
9
19
10
20

Yes, it's never going to be as optimal as an operator implemented by hand, but I'm afraid I don't think it's common enough to warrant adding and maintaining a whole new operator along with its tests.

I'm happy to reconsider if it can be demonstrated to be extremely common in some field.

@atifaziz atifaziz closed this as not planned Won't fix, can't repro, duplicate, stale Jan 20, 2023
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

No branches or pull requests

2 participants