Moreover, copying is not even meaningful in a functional setting. A data
structure is indistinguishable from a copy of the data structure. In
languages that allow mutation of data, one has to carefully copy data to
avoid accidental mutation by other computations. Disallow data mutation,
and the
Rouan van Dalen wrote:
It is important to store only a reference to the parent and not a copy of the
entire parent for efficiency.
Others have already recommended the rosezipper package, which gives you
what you want, but I want to address one thing.
foo =
bar = foo
In most implem
On Wed, Jun 17, 2009 at 9:24 AM, Miguel Mitrofanov wrote:
> You can use the standart "tying the knot"-technique. For example:
>
> data Tree = TreeNode String (Maybe Tree) [Tree] -- what's the parent of the
> root node?
>
> test :: Tree
> test =
> let parent = TreeNode "I'm parent" Nothing [child1
You can use the standart "tying the knot"-technique. For example:
data Tree = TreeNode String (Maybe Tree) [Tree] -- what's the parent of the
root node?
test :: Tree
test =
let parent = TreeNode "I'm parent" Nothing [child1, child2]
child1 = TreeNode "I'm child1" (Just parent) []