I have a sequence given below:
seq = {{1, 2}, {2, 1}, {2, 2}, {3, 2}, {3, 4}, {4, 2}, {5, 1}, {6,2},
{7, 3}, {8, 4}, {9, 2}, {10, 2}, {10, 3}, {10, 4}, {10,5}, {11, 2}}
I split the list according to the first element
splitlist = SplitBy[seq, First]
{{{1, 2}}, {{2, 1}, {2, 2}}, {{3, 2}, {3, 4}}, {{4, 2}}, {{5,1}},
{{6, 2}}, {{7, 3}}, {{8, 4}}, {{9, 2}}, {{10, 2}, {10,3}, {10, 4}, {10, 5}}, {{11, 2}}}
then decreasing the brackets by 1
splitlist //. {x_} :> x
{{1, 2}, {{2, 1}, {2, 2}}, {{3, 2}, {3, 4}}, {4, 2}, {5, 1}, {6,2}, {7, 3},
{8, 4}, {9,2}, {{10, 2}, {10, 3}, {10, 4}, {10, 5}}, {11, 2}}
Now i wish to find a repeated rule (//.) such that i can group all the consecutive lists of 2 elements together into a single list i.e. {... {{4, 2}, {5, 1}, {6,2}, {7, 3},{8, 4}, {9,2}} ....}
{{1, 2}, {{2, 1}, {2, 2}}, {{3, 2}, {3, 4}},
{{4, 2}, {5, 1}, {6,2}, {7, 3},{8, 4}, {9,2}},
{{10, 2}, {10, 3}, {10, 4}, {10, 5}}, {11, 2}}
Any pattern that can group sublists of elements 2 when they appear consecutively?