Task

Write a program to find the sum of squares of a numeric vector.

The program should work on a zero-length vector (with an answer of   0).



Related task

   Mean


sum(List, Sum) :-
    sum(List, 0, Sum).
 
sum([], Sum, Sum).
sum([X| Xs], Acc, Sum) :-
    Acc2 is Acc + X,
    sum(Xs, Acc2, Sum).