I am trying to solve some prolog exercises in order to learn the language and i have problem adding the numbers in a prolog list.
For example i have the list [1,2,3] and i want to have as output number 6.
I wrote this code but it is not working.
list_adder([H|T],S):- S is H + T.
can anyone explain why?
try this: