I'm really new to Haskell and programming in general. I'm trying to add up the contents of a list without using the sum function from Data.List. Here's what I've got so far:
module Summ
where
summ :: [Int] -> Int
summ xs =
if null xs == False
then let y = x + (head xs)
let xs = tail xs
else print y
I'm pretty sure there's a lot wrong with this code, but for now the latest error is "parse error on input" for the else statement. What's wrong?
yis defined in the first branch of your expression, but used in the second half. What are you expecting to happen?yas sort of storage for the expressions I'm using to add up the elements of the list. I couldn't think of another way to do it...