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_squares = proc (ns: sequence[int]) returns (int)
    sum: int := 0
    for n: int in sequence[int]$elements(ns) do
        sum := sum + n ** 2
    end
    return(sum)
end sum_squares
 
start_up = proc ()
    po: stream := stream$primary_output()
 
    stream$putl(po, int$unparse(sum_squares(sequence[int]$[])))
    stream$putl(po, int$unparse(sum_squares(sequence[int]$[1,2,3,4,5])))
    stream$putl(po, int$unparse(sum_squares(sequence[int]$[42])))
end start_up