Hi,

On 11 March 2012 13:36, bahadýr altan <doaltan@yahoo.co.uk> wrote:
... my function works on just first three nodes of  a binary tree, but the tree is bigger, I don't care the other nodes. Like this :

function Node a (Node b Subtree Subtree)  (Node c Subtree Subtree)  

Assuming you use the following declaration for your data type:

data Tree a = Leaf | Node a (Tree a) (Tree a)

The syntax you are looking for is the following; where x, y and z are pattern variables.

f :: Tree a -> (a,a,a)
f (Node x (Node y _ _) (Node z _ _)) = (x,y,z)

The above function is obviously partial. It would throw an exception if you apply it to anything which doesn't have the 'proper' shape. (e.g. "f Leaf")

I don't know your background, but I'd suggest reading some introductory material if you are having trouble understanding the above snippets. LYAH is a pretty fun read: http://learnyouahaskell.com

Hope this helps,
Ozgur