Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think Java did the right thing by making tree shaped collections, since they’re iterable and that covers the for loop situation, but it doesn’t expose the tree structure, so you can’t tell if two nodes are siblings or relatives or indeed if they are even in the same tree.

But I think grafting those two together is the right answer, not inventing a new loop construct.

Trees are easy to write iterators for. DAGs are a bit harder and full graphs are an advanced interview question.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: