3 ms·
well, functional languages with recursive types, are very good at representing binary trees https://cs3110.github.io/textbook/chapters/data/trees.html https:/
by systems 1y ago
well, functional languages with recursive types, are very good at representing
binary trees
https://cs3110.github.io/textbook/chapters/data/trees.html https://cs3110.github.io/textbook/chapters/data/trees.html
- tbct 1y agoOnce 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.