Sum array from input haskell using Num a => a [closed]
i have problem with haskell when i learn about sum every index in array,
acc :: (Num a) => a -> [t] -> [t]
acc _ [] = []
acc z (x:xs) = [(z) x] ++ (acc z xs)
my question is how to sum index from input user, input : acc (+10) [1,2,3] result : [11,12,13]
Solution 1:
Resolved with:
acc :: (a -> b) -> [a] -> [b]
acc _ [] = []
acc a (x:xs) = [a x] ++ (acc a xs)