Send Beginners mailing list submissions to beginners@haskell.org 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 beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org 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 <mike_k_hough...@yahoo.co.uk> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: [Haskell-beginners] Rose tree Message-ID: <adec9332-6f04-4c0b-8c27-a0f421283...@yahoo.co.uk> 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 Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 103, Issue 2 *****************************************