Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Questions About Rose Trees Analysis (Lorenzo Isella)
2. Re: Questions About Rose Trees Analysis (Henk-Jan van Tuyl)
----------------------------------------------------------------------
Message: 1
Date: Thu, 17 Dec 2015 11:37:24 +0100
From: Lorenzo Isella <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Questions About Rose Trees Analysis
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii; format=flowed
Dear All,
I am trying to learn Haskell (for the second time), but I have to
admit I am still struggling with relative simple stuff, so I ask if
anybody can give me a hand.
I am dealing with the issues of extracting info out of some rose trees
and probably I am also having some troubles with the notation.
The rose tree is defined with the following notation
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.
Any suggestion is appreciated.
Cheers
Lorenzo
------------------------------
Message: 2
Date: Thu, 17 Dec 2015 12:10:01 +0100
From: "Henk-Jan van Tuyl" <[email protected]>
To: [email protected], "Lorenzo Isella" <[email protected]>
Subject: Re: [Haskell-beginners] Questions About Rose Trees Analysis
Message-ID: <op.x9sby4aqpz0j5l@alquantor>
Content-Type: text/plain; charset=iso-8859-15; format=flowed;
delsp=yes
On Thu, 17 Dec 2015 11:37:24 +0100, Lorenzo Isella
<[email protected]> wrote:
:
>
> 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
--
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 90, Issue 34
*****************************************