[Haskell-beginners] Type Tree variables
Ozgur Akgun
ozgurakgun at gmail.com
Sun Mar 11 15:23:58 CET 2012
(Replying to the list again)
On 11 March 2012 14:15, bahadýr altan <doaltan at yahoo.co.uk> wrote:
> Hi,
> Thanks for your reply. I tried your solution but my function becomes
> like this and it gives an error on the right side :
>
function (Node a (Node b _ _) (Node c _ _)) = (Node c (Node a _ _) (Node b
> _ _))
>
This is not what you originally said though. If you need to refer to the
subtrees, you just need to name them. (Instead of using _)
[ not a very useful function, but still: ]
f :: Tree a -> Tree a
f (Node x (Node y y1 y2) (Node z z1 z2)) = Node x (Node y y1 y2) (Node z z1
z2)
-- also think about the types: (x, y, z :: a) (y1, y2, z1, z2 :: Tree a)
> The thing is I don't need to process the subtrees but I still have to
> return them as an output. I still can't do that. And I read a few chapters
> in LYAH, it was pretty good, I learned haskell from there. However, I think
> the answer of this question isn't in LYAH.
> Thanks..
> Bahadir
>
--
Ozgur Akgun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120311/3816a569/attachment.htm>
More information about the Beginners
mailing list