
Hello, I need help... I am having trouble with rose trees. 1 2 3 4 5 6 7 8 9 10 11 That is the rose tree that I seek. Data Tree a = Empty | Leaf a | Node a [(Tree a)] example :: Tree (String, String) example = Node ("a","b") -- root node [ ........................................] -- end of tree What I want to do is create two functions that return either the children or parents of a given input, here a String. String -> Tree -> [String] I think _________________________________________________________________ The next generation of MSN Hotmail has arrived - Windows Live Hotmail http://www.newhotmail.co.uk

I think it's not at all clear what you're asking for here. can you
give an example inputs and outputs you'd expect? It looks like you're
trying to implement some kind of dictionary or something? Also, have
you looked at the library Data.Tree? It might be useful for you.
On 11/3/07, Ryan Bloor
Hello,
I need help... I am having trouble with rose trees.
1
2 3 4 5 6 7 8 9 10 11
That is the rose tree that I seek.
Data Tree a = Empty | Leaf a | Node a [(Tree a)]
example :: Tree (String, String) example = Node ("a","b") -- root node [ ........................................] -- end of tree
What I want to do is create two functions that return either the children or parents of a given input, here a String. String -> Tree -> [String] I think
________________________________ Play Movie Mash-up and win BIG prizes! _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Hi Ryan,
I need help... I am having trouble with rose trees.
You've come to the right place! If this is homework, please look at: http://www.haskell.org/haskellwiki/Homework_help (But have patience. haskell.org seems to be bogged down at the moment, probably because of the release within the past few hours of a new version of the GHC compiler.)
Data Tree a = Empty | Leaf a | Node a [(Tree a)] example :: Tree (String, String) What I want to do is create two functions that return either the children or parents of a given input, here a String. String -> Tree -> [String] I think
Good idea to start with a type signature. Sounds like you want something more general than just String, though. Try to write out the exact type signature you want. When you've got that, give a try at writing the functions If you get stuck at any point, send us what you've got so far. Good luck, Yitz

Ryan Bloor:
Data Tree a = Empty | Leaf a | Node a [(Tree a)]
The Leaf constructor seems superfluous to me. Any (Leaf x) value is equivalent to (Node x []). So I rather just have data Tree a = Empty | Node a [Tree a] which will mean less work for your task of writing processing functions, too. Kalman ---------------------------------------------------------------------- Get a free email account with anti spam protection. http://www.bluebottle.com/tag/2
participants (4)
-
Andrew Wagner
-
Kalman Noel
-
Ryan Bloor
-
Yitzchak Gale