Given a list list
, how can it be transformed so that every three elements selected from left to right form a sublist, with the first two elements of each sublist enclosed in curly braces? The result should be list1
.
list = {a, b, c, a, b, d, a, b, e, a, b, f, a, b, g}
list1 = {{{a, b}, c}, {{a, b}, d}, {{a, b}, e}, {{a, b}, f}, {{a, b},
g}}
I attempted this approach, but it didn't yield the correct results.
list = {a, b, c, a, b, d, a, b, e, a, b, f, a, b, g};
list1 = Apply[{{#1, #2}, #3} &, Partition[list, 3]]