I\'d like to take input such as:
[1,2,4,5,6,7,9,13]
and turn it into something like the following:
[[1,2],[4,7],[9,9],[13,1
Hmm, well, it's not tokland's masterpiece, but I think it may be a good straightforward solution...
[1,2,4,5,6,7,9,13].inject([]) do |m, v| if m.last.to_a.last == v.pred m[-1][-1] = v else m << [v, v] end m end