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

well, functional languages with recursive types, are very good at representing binary trees

https://cs3110.github.io/textbook/chapters/data/trees.html



Once you have algebraic data-types in a language, writing a recursive visitor pattern is pretty simple.

Encoding the semantics of a tree traversal operator likewise is difficult in the general case. What exactly would the order be, what if I want to traverse in a non-standard ordering, what about skipping branches; all would be difficult to cleanly represent.

I have seen it done where you return actions with key ones being recurse, stop, replace, and replace & then carry out some function, but again, this is pretty simple to implement.




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

Search: