using System.Collections.Generic;
public static void Main()
var source = new[] { 1, 1, 4, 6, 3, 3, 1, 2, 2, 2, 6, 6, 6, 7 };
IEnumerable<IGrouping<int, int>> grouped = MoreLinq.MoreEnumerable
.GroupAdjacent(source, x => x);
foreach (var group in grouped)
Console.WriteLine($"Key: {group.Key}, Elements: {String.Join(", ", group)}");
IEnumerable<KeyValuePair<int, int>> pairs = MoreLinq.MoreEnumerable
.RunLengthEncode(source);
foreach (var pair in pairs)
Console.WriteLine($"Key: {pair.Key}, Value: {pair.Value}");