[Haskell-cafe] Re: I just don't get it (data structures and OO)
Donald Bruce Stewart
dons at cse.unsw.edu.au
Sun Jun 3 05:03:23 EDT 2007
apfelmus:
> Phlex wrote:
> > Donald Bruce Stewart wrote:
> >>
> >> Imagine updating a node in a tree by just detaching and reattaching a
> >> pointer.
> >>
> >> [1] [1]
> >> / \ / \
> >> [2] [3] update node 5 [2] [3]
> >> / \ with value 7 / \
> >> [4] [5] [4] *
> >>
> >> and share the rest of the structure. Since the rest isn't mutable
> >> anyway, you can share all over.
> >
> > That's precisely the thing i don't understand.
> > In order to update node 3 with a new pointer, i need to mutate it, so i
> > need to recreate it, and so on up to node 1.
>
> Yes, that's correct, I think Dons shared a bit too much here :)
Spent too much time with zippers lately ;)
-- Don
More information about the Haskell-Cafe
mailing list