distinctConsecutiveEnclosingBy

inline fun <T, K> Iterable<T>.distinctConsecutiveEnclosingBy(crossinline selector: (T) -> K): List<T>

Returns a list without consecutive elements which have the same return by the given selector function. The operation is performed enclosing around the list, meaning that the selector(lastElement) == selector(firstElement) is also evaluated.

Receiver

the base list for which the consecutive duplicates according to the selector are being removed

Return

list without consecutive duplicates (also potentially enclosing duplicates)

Parameters

selector

if the resulting elements of the selector is equal, the duplicates are being removed