So i'm not too sure how to phrase this properly, but say I wanted to get the sum of all odd numbers in a list, do I have two functions (sumList and getOddNumbers) and combine them into sumOddList or is there a way to put these two together in a single function? If there isnt a better function, how exactly would I combine them into sumOddList?
getOddNumbers :: [Integer] -> [Integer]
getOddNumbers [] = []
getOddNumbers (x:xs)
|odd x = x:getOddNumbers xs
|otherwise = getOddNumbers xs
sumList :: [Integer] -> Integer
sumList list = case list of
[] -> 0
(x:xs) -> x + (sumList xs)
I also ask mainly because putting two diff functions together is something I struggled with before, when putting a colour and a shape using CodeWorld to output a shape of that colour.
Thank you
(Note: I've been using Haskell for just over 5 weeks now and I'm a total noob clearly)