Suppose I had a string:
string str = \"1111222233334444\";
How can I break this string into chunks of some size?
e.g., breaking t
public static IEnumerable> SplitEvery(this IEnumerable values, int n)
{
var ls = values.Take(n);
var rs = values.Skip(n);
return ls.Any() ?
Cons(ls, SplitEvery(rs, n)) :
Enumerable.Empty>();
}
public static IEnumerable Cons(T x, IEnumerable xs)
{
yield return x;
foreach (var xi in xs)
yield return xi;
}