zipWithConsecutives

fun <T, K> Iterable<T>.zipWithConsecutives(keySelector: (T) -> K): List<List<T>>

Zips consecutive elements of the original list by the key returned by the given keySelector function applied to each element and returns a list where each containing list holds the selected elements.

Receiver

contains the elements which are zipped

Return

list of all zipped elements (also represented as list), whereas the returned nested lists preserve the iteration order

Parameters

keySelector

if keySelector of consecutive elements return equal objects, zipping is performed