re: A concatenated iterator example in Kotlin VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Hm...what about fun countAll(nodes: List<Node>): Int = nodes.size + nodes.sumBy { countAll(it.children) } ? I'm more curious abou...
 

Hi Max A. That recursive version is definitely more efficient than my tail recursive one as its stack size is smaller and doesn't have the overhead of the accumulation. What I wanted to focus on is the iteration across multiple lists and couldn't come up with a better example. Regarding the profiling tool, it's a pretty useful one and it's here: github.com/jvm-profiling-tools/asy...

Enjoy :)

code of conduct - report abuse