sum(+List, -Sum)
Succeeds with Sum equal to the sum of all the entries on list. The empty list has sum 0, and if List is not a list of numeric values, sum fails or results in an error.
It is nearly close but I got this so far...
sum([], 0) :- !.
sum(N, N) :- number(N), !.
sum([H|T], N) :-...