
The zipper should work on n-ary trees. all the zipper does is store the tree as (Context,Subtree) so you just need to adapt that to a Rose-Tree. you could do something like (and I am thinking out loud here as I havent written zipper code for rose trees)... data Context x = Root | Parent x (Context x) [Rose x] [Rose x] data Rose x = Node x [Rose x] so at any given point in the tree the context is either Root, or the Parent (with the value at that node, the parents context, then the left siblings and right siblings as lists) As to the difference between types and values, a type limits the permitted values. For example a :: [Int] a is a list of integers. now data IntList = Value Int | List [Int] IntList can be a single int or a list of ints... data IntList = Value Int | List [IntList] Now intlist can be a value or a list of IntLists... we are dealing with the type of permitted data not the data itself. when we define a value for example: a :: IntList a = Value 3 This must obey the construction rules given in the data type "IntList" So you see when a data declaration refers to itself it is not a "pointer" but an inclusion of the type for example: a :: IntList a = List [Value 3,List [Value 2,Value 1],Value 4] is a valid instance of IntList, but notice that although the 'type' refers to itself the value is not self-referential. Thats not to say self referential values are not possible - but lets avoid confusing the issue with such things. Keean.

On Sat, 3 Jul 2004 17:57:04 +0100 (BST), MR K P SCHUPKE
The zipper should work on n-ary trees. all the zipper does is store the tree as (Context,Subtree)
What is the meaning of storing in haskell? Imagine I put numbers in the leaves...
you could do something like data Context x = Root | Parent x (Context x) [Rose x] [Rose x] data Rose x = Node x [Rose x] Should the numbers be of type x ,right?? So x is Int. -5 | -2-6 | 1-3 | -4
context of 1 is Root.Where do I store the 1?I Subtree?The name is misleading me... context of 2 is Parent 1 Root .....and then To make it easy I don't mind siblings I just want sons
so at any given point in the tree the context is either Root, or the Parent (with the value at that node, the parents context,
What do you mean with the parents context?Is it the substitution for the pointer? Which is the tracker function? tracker (context,???) | (Root,???) = [kkkk] kkkk should be the node 1 where can I get it? | (Parent p (Contetx c)....,???) = tracker (c,?!?):kkkk I feel terrible ........ Paolino
participants (2)
-
MR K P SCHUPKE
-
paolo veronelli