Created
March 19, 2014 19:26
-
-
Save gkossakowski/9649344 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def grouped[T](xs: Seq[T], n: Int): Iterator[Seq[T]] = { | |
val (segment, rest) = xs.splitAt(n) | |
Iterator(segment) ++ (if (rest.isEmpty) Iterator.empty else grouped(rest, n)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment