I need to write a function in Haskell that sums the elements of a list until some specific elements stored in another list.
For example partial_add [1,2,3,4,5,
Thank to your answers i figured it out. I needed to declare the type of the function and put the parenthesis where they should be. The code was indeed not working as it should but i fixed that to.
Here is the fixed code:
partial_add :: [Int] -> [Int] -> Int -> [Int]
partial_add [] _ count = [count]
partial_add (a:x) list count | elem a list = (count+a):partial_add x list 0
| otherwise = partial_add x list (count+a)
It may not be the best possible but it worked out for me.