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,6] [2,5] 0 should return [3,12,6].
I have reached this far:
partial_add [] _ count = []
partial_add (a:x) list count | elem a list = count:partial_add x list 0
| otherwise = partial_add x list count+a
(most probably not working properly)
But when I try to run the function (it compiles properly) I get this error:
No instance for (Num [t0]) arising from a use of `it'
In a stmt of an interactive GHCi command: print it
Any idea what's going on?
partial_add x list count+ais interpreted as(partial_add x list count)+anotpartial_add x list (count+a).partial_add's type. Then try to add the correct type signature yourself.avalue gets lost ifa `elem` listholds, so you may want to adjust that case.