Any way to tail-recurse this?



Just adding up numbers in a list. I already know you could do the
below better, cleaner, and in fewer steps. My question is how to tail-
recurse it, if possible.

(the first arg in the predicate is the list, the second is the
"total")

Thanks.
---------------------

addlist([],0).
addlist([X],X).
addlist([H|[X]],Y) :- Y is H+X. %This pred is probably unnecessary,
but aids my understanding
addlist([H1|[H2|T]],Y1) :- addlist([H2|T],Y2), Y1 is H1+Y2.

.