|
 |
Darren New wrote:
> I realized why I thought trees in an OO language have child nodes with
> null branches - It's OO. You have pointers to things. In Haskell, it's
> expected that when you add a new leaf down at the bottom of the tree,
> the root node changes. In OO, you don't want to have to reassign all
> variables holding pointers to the root when you add a leaf. And that
> applies recursively as well. Even balancing a tree, you tend to rotate
> the child pointers rather than reassign the parent pointer, per se.
More succinctly: In OO, trees are usually mutable. In Haskell, trees are
usually immutable.
> So that's at least part of it.
A bigger part of it is that, while essentially Haskell has pointers,
null pointers are explicitly prohibited.
Post a reply to this message
|
 |