dimanche 30 mars 2014

Non-exhaustive patterns in function error


Vote count:

0




In haskel, I got an error and somehow I couldn't find the right solution. There is the error i get and my code:


My code:



data MyTree = Leaf Float | Tree String MyTree MyTree deriving (Show, Eq, Ord)

asgCodeRec1 [] _ = []
asgCodeRec1 (a:b:c) (y:ys) = [Tree (y) (Leaf a) (Leaf b)] ++ asgCodeRec1 c ys

asgCode2 (a:b:c) (x:xs) = [Tree x a b] ++ (if c/=[] then (asgCode2 c xs) else [])

asgCode c y = asgCode2 (asgCodeRec1 c y) (drop (length c * 2) y)


and my console log:



*Main> asgCode [0.5,0.5,0.5,0.5,0.5,0.5] ["and","and","and","or","or"]
*** Exception: part1.hs:6:1-81: Non-exhaustive patterns in function asgCode2


Any help is useful. Thanks.



asked 24 secs ago






Aucun commentaire:

Enregistrer un commentaire