Given a List such as
List(1, 2, 3, 4, 5, 6, 7)
what is the best way to split it into n sub-lists, putting items into each list in a round-robin fashion?
e.g. if n = 3, the result should be
List(List(1, 4, 7), List(2, 5), List(3, 6))
I thought there would be a method in the collections API to do this, but I can’t seem to find it.
Bonus points for classy one-liners 😉
1 Answer