I might draw a list of words like:
this -> is -> a -> test
and then through sharing, I might draw two lists as:
this -> is -> a -> test
^
|
that -> was -> a -> hard
Now, if I reverse the arrows, I get a tree, with test as the root. This is the same notion as duality in graph/category theory. Therefore, I can think of trees and lists as dual concepts.
Is this correct/useful?
Sharing and laziness allow you to have arbitrary cyclic structures. For example, in Haskell the definition
ones = 1 : ones
produces a graph consisting of a single vertex (corresponding to 1) and a loop (in graph-theoretic, not programming sense). By reversing the arrows, you'd get the same structure, and it's not a tree (as it's got loops).
So, it's not true in a lazy language.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With