-
Notifications
You must be signed in to change notification settings - Fork 416
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
Spread tuples: [(x, x), (x, x), …] → [x, x, x, x, …] #939
Comments
I would argue this is a fancier more opinionated version of |
@viceroypenguin Do you mean |
Sure, what you're describing here is basically sequence generation for a single Reversing operation: |
Ah, you mean a generator for inner sequence? So you're saying (a) is the more general version of (b)? Do you mean the below? public static IEnumerable<U> Spread<T, U>(this IEnumerable<T> source, Func<T, (U, U)> selector)
{
foreach (var item in source)
{
var (a, b) = selector(item);
yield return a;
yield return b;
}
} |
a) and b) are orthogonal to each other. a) This is just my argument, feel free to ignore if I'm wrong. :) |
That looks like public static IEnumerable<T> AsEnumerable<T>(this (T Left, T Right) pair)
{
yield return pair.Left;
yield return pair.Right;
} |
@declard Not quite. That would be |
I propose to add a new operator that takes a sequence of tuples and spreads the elements of each tuple into the resulting sequence:
Additional overloads can be supplied for remaining multary tuple types.
Example:
Outputs:
This would be more generally usable than what's proposed in #695.
The text was updated successfully, but these errors were encountered: