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

IEnumerable.SelectPairs() #79

Closed
GoogleCodeExporter opened this issue Mar 23, 2015 · 4 comments
Closed

IEnumerable.SelectPairs() #79

GoogleCodeExporter opened this issue Mar 23, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

Hi I was wondering if it would be possible to include Jon's SelectPairs() 
extension from http://stackoverflow.com/a/619180/91551 ? Code below:

using System.Collections.Generic;

// This must be a non-nested type, and must be static to allow the extension
// method.
public static class Extensions
{
    public static IEnumerable<TResult> SelectPairs<TSource, TResult>
        (this IEnumerable<TSource> source,
         Func<TSource, TSource, TResult> selector)
    {
        using (IEnumerator<TSource> iterator = source.GetEnumerator())
        {
           if (!iterator.MoveNext())
           {
               yield break;
           }
           TSource prev = iterator.Current;
           while (iterator.MoveNext())
           {
               TSource current = iterator.Current;
               yield return selector(prev, current);
               prev = current;
           }
        }
    }
}

Original issue reported on code.google.com by rdingw...@gmail.com on 12 Dec 2012 at 1:59

@GoogleCodeExporter
Copy link
Author

Code attached even. Added XML comments and your license at the top.

Original comment by rdingw...@gmail.com on 12 Dec 2012 at 2:00

Attachments:

@GoogleCodeExporter
Copy link
Author

Original comment by rdingw...@gmail.com on 12 Dec 2012 at 2:01

Attachments:

@GoogleCodeExporter
Copy link
Author

It's already there and it's called Pairwise:
http://code.google.com/p/morelinq/source/browse/MoreLinq/Pairwise.cs?name=1.0.15
416-beta

If you are using the NuGet package, update to the pre-release:
http://nuget.org/packages/morelinq/1.0.15416-beta

Original comment by azizatif on 12 Dec 2012 at 5:58

  • Changed state: WontFix

@GoogleCodeExporter
Copy link
Author

Ah oops - thanks!

Original comment by rdingw...@gmail.com on 12 Dec 2012 at 7:05

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

No branches or pull requests

1 participant