Dividing a list in specific number of sublists

Posted by Surya on Stack Overflow See other posts from Stack Overflow or by Surya
Published on 2010-05-21T18:03:20Z Indexed on 2010/05/21 19:50 UTC
Read the original article Hit count: 134

I want to divide a list in "a specific number of" sublists.

That is, for example if I have a list List(34, 11, 23, 1, 9, 83, 5) and the number of sublists expected is 3 then I want List(List(34, 11), List(23, 1), List(9, 83, 5)).

How do I go about doing this? I tried grouped but it doesn't seem to be doing what I want.

PS: This is not a homework question. Kindly give a direct solution instead of some vague suggestions.

© Stack Overflow or respective owner

Related posts about scala

Related posts about list