Farrel Lifson wrote: > Hi folks, > > Is there an easy way to get [1,2,3,4,5,6,7,8] into > [[1,2],[3,4],[5,6],[7,9]] or [[1,2,3,4],[5,6,7,8]] depending on a > parameter? > > Farrel [1,2,3,4,5,6,7,8].inject([[]]){|a,x| a.last.size==2 ? a << [x] : a.last << x ; a }