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.  Rose tree (mike h)


----------------------------------------------------------------------

Message: 1
Date: Sun, 8 Jan 2017 20:06:33 +0000
From: mike h <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] Rose tree
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8

Hi,

I’m rapidly descending into a spiral of confusion! :)

How do I add something to a rose tree? 

I have 

data Tree a = Node a [Tree a] deriving (Show)

add :: Eq a => a -> a -> Tree a -> Tree a

and the first ‘a’ is the thing to add and the second is its parent node.
i.e. 
add :: Eq a => a -> a -> Tree a -> Tree a
add x px (Node x' []) = Node x' [Node x []]
…..

I’ve tried various ways for the more general case but always seem to lose part 
of the tree.

Any advice would be very welcome.

Thanks

Mike

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 103, Issue 2
*****************************************

Reply via email to