I need to create batches from a lazy enumerable with following requirements:
- Memory friendly: items must be lazy loaded even within each batch (
IEnumerable<IEnumerable<T>>
, excludes solution building arrays) - the solution must not enumerate twice the input (excludes solutions with
Skip()
andTake()
) - the solution must not iterate through the entire input if not required (exclude solutions with
GroupBy
)
The question is similar but more restrictive to followings: