Scala's collection have a lot of interesting methods like grouped, take and drop. Another one that I didn't know was sliding. It behaves like a sliding window, i.e. it always takes X elements where the X-1 come from the previous block:
"sliding of 3 for 7-elements sequence" should "return 5 sliding blocks" in { val letters = Seq("a", "b", "c", "d", "e", "f", "g") val slidingBlocks = letters.sliding(3).toSeq slidingBlocks should have size 5 slidingBlocks should contain allOf(Seq("a", "b", "c"), Seq("b", "c", "d"), Seq("c", "d", "e"), Seq("d", "e", "f"), Seq("e", "f", "g")) }