[Haskell] Binary Tree Traversal.

Paul Chen 2ypc at qlink.queensu.ca
Tue Mar 8 18:53:26 EST 2005


data BinTree a = Nil | Node a (BinTree a) (BinTree a)

inorder2 :: BinTree a -> [a] -> [a]
inorder2 Nil xs = []
inorder2 (Node val b1 b2) xs = (inorder2 b1 (val:(inorder2 b2 (xs))))

I want to be able to traverse across the binary tree in order and that 
is what I have so far.
But somehow it always return []. it seems to ignore the "val:"

Y. C.


More information about the Haskell mailing list