It is strange that groupByit is not on Iterator, but what about this?
val it = Iterator(1, 2, 3)
new Iterable[Int] { def iterator = it }.groupBy(_ % 2 == 0)
This seems to work (although this is by no means guaranteed, given that it must produce the same iterator c each time Iterable).
source
share