Your pattern in the head of the function "chromoResult (a:b:c:xs)" requires the list to have at least three elements in it. I doubt that all the recursive calls take this into consideration...
2009/10/27 satorisanitarium <[email protected]>: > I'm trying to parse a list of numbers plus four diferent signs (+-*/) > in this way: > > Lets say the list is "32+5/46" result would be "2+5/4" > I get: > > "2+5/4*** Exception: geneticSimple.hs:(55,0)-(65,35): Non-exhaustive > patterns in function chromoResult > > If the list is "32+5**6" result would be "2+5*6" > I get: > "2+5/*** Exception: geneticSimple.hs:(55,0)-(65,35): Non-exhaustive > patterns in function chromoResult > > If the list is "32+-72" resoult would be "2+7" > I get: > "2+*** Exception: geneticSimple.hs:(55,0)-(65,35): Non-exhaustive > patterns in function chromoResult > > code: > > chromoResult [] = [] > chromoResult (a:b:c:xs) > | elem a "0123456789" && elem b "0123456789" && elem c "0123456789" = > chromoResult (c:xs) > | elem a "0123456789" && elem b "0123456789" && elem c "+-*/" = b:c: > chromoResult xs > | elem a "0123456789" && elem b "+-*/" && elem c "0123456789" = > a:b:c : chromoResult xs > | elem a "0123456789" && elem b "+-*/" && elem c "+-*/" = a:b : > chromoResult (c:xs) > | elem a "+-*/" && elem b "0123456789" && elem c "0123456789" = > chromoResult (b:c:xs) > | elem a "+-*/" && elem b "0123456789" && elem c "+-*/" = b:c : > chromoResult xs > | elem a "+-*/" && elem b "+-*/" && elem c "0123456789" = > chromoResult (c:xs) > | elem a "+-*/" && elem b "+-*/" && elem c "+-*/" = chromoResult xs > | otherwise = chromoResult (b:c:xs) > > I suspect my approach is flawed but i have exausted my ideas. > I need a fresh approach so if anybody would be kind enough and just > give me a hint how to approach the problem. > Thx in advance. > _______________________________________________ > Haskell-Cafe mailing list > [email protected] > http://www.haskell.org/mailman/listinfo/haskell-cafe > _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
