
On Thu, 17 Dec 2015 11:37:24 +0100, Lorenzo Isella
data Rose a = a :> [Rose a] deriving (Eq, Show)
and the root can be detected simply as
root (a :> rs) = a
I would like to have the expression (with the ":>" notation for the Node) of the function to find the children of the root. Example of expected behavior of this function children
children (1 :> [2 :> [], 3 :> []]) = [2 :> [], 3 :> []]
On top of that, I am trying to get the functions to have the functions
size :: Rose a -> Int leaves :: Rose a -> Int
that count the number of nodes in a rose tree, respectively the number of leaves (nodes without any children). For the children function, I have tried stuff like
children (a :> rs) = rs
quite unsuccessfully.
: Your definition of children is correct, what is the message you get from the compiler/interpreter? Regards, Henk-Jan van Tuyl -- Folding@home What if you could share your unused computer power to help find a cure? In just 5 minutes you can join the world's biggest networked computer and get us closer sooner. Watch the video. http://folding.stanford.edu/ http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming --