fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
sum' :: (Integral a) => [a] -> a
sum' [] = 0
sum' [a] = foldr (+) 0 ([a])
main = do putStrLn "Enter a number:"
num <- readLn
sum' (take num fibs)
That's my code to take the sum of a recursively produced list.
I could have done the foldr operation at take num fibs, but I wanted more control over the list and wanted a way in which I could take the sum of particular elements of a list rather than the whole list.
Where am I going wrong?