Skip to content

Instantly share code, notes, and snippets.

@Grabacr07
Last active August 29, 2015 14:07
Show Gist options
  • Save Grabacr07/51f2e625c4397fa91d9c to your computer and use it in GitHub Desktop.
Save Grabacr07/51f2e625c4397fa91d9c to your computer and use it in GitHub Desktop.
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