IEnumerable.SelectPairs()
Closed this issue · 4 comments
GoogleCodeExporter commented
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 commented
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 commented
GoogleCodeExporter commented
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 commented
Ah oops - thanks!
Original comment by rdingw...@gmail.com
on 12 Dec 2012 at 7:05