The eighteenth video in my exploring MoreLINQ series looks at the
Segment extension methods.
These methods are ideal if you ever need to partition a sequence up into chunks of adjacent elements, but those chunks are not all of the same size like they would be if you simply used
For example, to solve "Longest Sequence" problem in my LINQ challenge #3, you needed to group a sequence of sales per day into sections of days with consecutive sales and days with no sales. It's quite tricky to achieve with regular LINQ operators, but the
GroupAdjacent method makes it straightforward.
You can find all videos in this series here.