|
|
|
|
|
by alterom
414 days ago
|
|
Sure, and perhaps that's the reason why we don't have a built-in for_tree: for some people, order matters; for others, it doesn't. Then, for some cases, depth-first traversal is needed; for others, breadth-first. Then, there's parallelism, and even the plain old for loops aren't parallel by default. By the time you specify exactly what you need from a tree traversal, you've written code to do it. And if you're fine with some default choice — you already can use the default iterator with the for_each loop. I don't see what need there is for adding an extra for_tree syntax to do that. |
|
Trees are often considered too diverse to include even in the standard library, let alone as a primitive. Even Python doesn't have trees in the standard library. I'm sure it's been proposed and rejected at some point