Last active
August 29, 2015 14:07
-
-
Save Grabacr07/51f2e625c4397fa91d9c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static class Extensions | |
{ | |
public static IEnumerable<T[]> ふぁぼツバめそっど<T>(this IEnumerable<T> source, Func<T, bool> predicate) | |
{ | |
var buffer = new List<T>(); | |
foreach (var value in source) | |
{ | |
if (predicate(value)) | |
{ | |
buffer.Add(value); | |
} | |
else if (buffer.Count > 0) | |
{ | |
yield return buffer.ToArray(); | |
buffer.Clear(); | |
} | |
} | |
if (buffer.Count > 0) | |
{ | |
yield return buffer.ToArray(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment