Why flatten a tree when you can just traverse it?

Michael Feathers wrote a blog post about avoiding explicitly traversing a tree recursively by taking advantage of its representation as nested arrays and using array operations to flatten.

I was unhappy about this solution because

So I wrote up the recursive solution. Some features of the solution:

Here’s the code:

comments powered by Disqus