
21 Apr
2009
21 Apr
'09
3:05 p.m.
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.