A haskell error message

Hi, I have been trying to specify the depth-first numbering algorithm as follow:
_dfNum :: Int -> [Tree a] -> [Tree Int] _dfNum i ((Node n ts):us) = (Node i vs):(_dfNum (i+1+(length ts)) us) where vs=_dfNum (i+1) ts
But when I test it, I receive the message: Non-exhaustive patterns in function _bfNum Please, could you give me an idea of how I could fix this? Thanks Kind regards, Ayawoa Sitsopé Dagbovie African Institute for Mathematical Sciences #6 Melrose Road Muizenberg 7945 South Africa. Phone: +27 782 960453

Am Dienstag 21 April 2009 20:52:40 schrieb siso dagbovie:
Hi,
I have been trying to specify the depth-first numbering algorithm as follow:
_dfNum :: Int -> [Tree a] -> [Tree Int] _dfNum i ((Node n ts):us) = (Node i vs):(_dfNum (i+1+(length ts)) us) where vs=_dfNum (i+1) ts
But when I test it, I receive the message:
Non-exhaustive patterns in function _bfNum
Please, could you give me an idea of how I could fix this?
First, you need to provide a case for the empty list _dfNum _ [] = [] to tell GHC what to do at the end of the list of trees. Second, if Tree a has other constructors than Node, you must also provide cases to tell GHC what to do when a list-element uses those constructors.
participants (2)
-
Daniel Fischer
-
siso dagbovie