Slide 58
Slide 58 text
List Partitions
• We can use partition over a list for obtain 2 lists
scala> List(1, 2, 3, 4, 5) partition (_ % 2 == 0)
res: (List[Int], List[Int]) = (List(2, 4),List(1, 3, 5))
// partition the values 1 to 10 into a pair of lists of even and odd numbers
assertEquals(Pair(listOf(2, 4, 6, 8, 10), listOf(1, 3, 5, 7, 9)), (1..10)
.partition{ it % 2 == 0 })