partitionRunsBy

fun <E, K> List<E>.partitionRunsBy(groupingKey: (E) -> K): List<List<E>>

Given a list and a key-extraction function, produce a list of non-empty lists of elements that have the same key. Note that it only looks for runs of a key, and treats reoccurrences of some key after a gap to be a new key.

Receiver

The list of elements.

Return

A list (empty iff the receiver is empty) of non-empty lists, each producing the same key. Note that flattening this list produces the original list.

Parameters

groupingKey

The key extraction lambda.