I did solve it at this way
I had my causes all wrong

-- | sum all the digits of a array
sumDigits :: [Integer] -> Integer
sumDigits n
   | n == 0 = acc
   | n < 10 = acc + n 
   | otherwise = sumDigits acc + n `mod` 10 + n `rem` 10
  

Roelof




yi lu schreef op 7-2-2015 om 10:01:
Do not try to `sum` all at first. See how you can deal with one integer.

On Sat, Feb 7, 2015 at 4:53 PM, Roelof Wobben <r.wobben@home.nl> wrote:
Hello,

The exercises of CIS 194 are really hard.

Now I have to sum all the numbers in a array with a catch
If a number is greater then 10 it has to be dived in single numbers.

so [ 1 , 12, 3] will be [ 1, 1,2,3] and then sum up.

So far I have this :

-- | sum all the digits of a array
sumDigits :: [Integer] -> Integer
sumDigits n
   | n == 0 = acc
   | n < 10 = acc + n
   | otherwise = sumDigits acc + n `mod` 10 + n `rem` 10


But now I see a message that acc is not known which is not wierd.

But when I do sumDigits n acc I see a message that sumDigits has only 1 parameter where I give it to,

When I only had to sum up i is easy , I could use map [+] xs

Anyone  who can give a me tip without giving the answer otherwise I do not learn anything.

Roelof

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners



_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners