Skip to main content
3 of 4
added 221 characters in body
user1066
  • 22.7k
  • 3
  • 36
  • 59
SequenceSplit[list, {a_, b_, c_} :> {{a, b}, c}]

(* {{{a, b}, c}, {{a, b}, d}, {{a, b}, e}, {{a, b}, f}, {{a, b}, g}} *)

Or

MapApply[{{#1, #2}, #3} &]@Partition[list, 3]

 (* {{{a, b}, c}, {{a, b}, d}, {{a, b}, e}, {{a, b}, f}, {{a, b}, g}} *)

Or

MapThread[{{#1, #2}, #3} &, Transpose@Partition[list, 3]]


(* {{{a, b}, c}, {{a, b}, d}, {{a, b}, e}, {{a, b}, f}, {{a, b}, g}} *)

In addition, using the undocumented (but very useful) fifth argument of Padding

Partition[list, 3, 3, 1, {}, {{#1, #2}, #3} &]

(* {{{a, b}, c}, {{a, b}, d}, {{a, b}, e}, {{a, b}, f}, {{a, b}, g}} *) 
user1066
  • 22.7k
  • 3
  • 36
  • 59