How do I split a sequence into two lists by a predicate?
Alternative: I can use filter and filterNot, or write my own method, but isn't there a better more general (built-in) method ?
filter
filterNot
By using partition method:
partition
scala> List(1,2,3,4).partition(x => x % 2 == 0) res0: (List[Int], List[Int]) = (List(2, 4),List(1, 3))
1.4m articles
1.4m replys
5 comments
57.0k users