Another way of doing it with an auxiliary object:
val average = sensorFlux.map { it.measure }
.map { Measure(1, it) }
.reduce { t: Measure, u: Measure -> Measure(t.elements + u.elements, t.sum + u.sum) }
.map { it.sum / it.elements }
---
data class Measure(var elements: Int, var sum: Long)