Essentially, these seem to me both variations of a sliding window, differing in: window size, step size and what to do when the underlying collection ends (split
returns non-full windows, adjacentPairs
stops iteration).
These parameters could be added to the wrapper type built for adjacentPairs
@mpangburn mentioned in the other thread, then both adjacentPairs
and split
could be implemented using that. Advanced users could use the wrapper directly to get more custom behaviour (a bigger window sliding one at a time to calculate statistics, iterating a list n elements at a time with one overlapping item, ...).
One negative this could potentially bring is allowing the wrapper to return non-full windows could make it harder to allow it to return constant-size subsequences once we have variadic generics.