Sum function in haskell producing 'Non-exhaustive pattern' error
Here is an example of my code that is producing the error:
amount :: [Int, Int, Int] -> Int
amount [(a, b, c)] = sum( map getBalance [(a, b, c)])
where getBalance :: (Int,Int,Int) -> Int
getBalance (d, e, f) = f
amount [] = 0
Originally the code was just:
amount :: [Int, Int, Int] -> Int
amount [(a, b, c)] = sum [c]
But I tried rewriting and adding things to see if I could find the cause
of the error, and I couldn't. I'm rather new to Haskell, so if it's a
stupid error I apoligise.
No comments:
Post a Comment