inline fun Iterable.foldMap( initial: R, operation: (R, T) -> Pair, ) = buildList { this@foldMap.fold(initial) { acc, element -> val (newAcc, newElement) = operation(acc, element) add(newElement) newAcc } }