There are times when you wish that you could just split a list into sublists without going into the for and while loops. Kotlin provides you with a function just for this occasion. In this recipe, we will see how to split a list based on some criteria.
Splitting original collection into pair of collections
Getting ready
I'll be using IntelliJ IDEA for writing and running Kotlin code; you are free to use any IDE that can do the same task.
How to do it…
Kotlin provides a partition function. According to the documentation of the partition function it does the...