How to split a sequence into two pieces by predicate?

By using partition method:

scala> List(1,2,3,4).partition(x => x % 2 == 0)
res0: (List[Int], List[Int]) = (List(2, 4),List(1, 3))

Leave a Comment