Hi guys! Is there any way to exit-early/short-circuit from the
reduce
function?
I wan’t to reduce an infinite sequence of numbers, but only until some condition is met (based on the result of the reduce).
I know Clojure has this neat
reduced
function for this. In Haskell we could use
scan
. But do we have anything similar in Kotlin’s stdlib?
a
Andreas Sinz
12/02/2018, 11:43 AM
It depends on the surroundings, for example this short-circuits `reduce`: