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


$ include "seed7_05.s7i";
  include "float.s7i";
 
const array float: list1 is [] (3.0, 1.0, 4.0, 1.0, 5.0, 9.0);
const array float: list2 is 0 times 0.0;
 
const func float: squaredSum (in array float: floatList) is func
  result
    var float: sum is 0.0;
  local
    var float: number is 0.0;
  begin
    for number range floatList do
      sum +:= number ** 2;
    end for;
  end func;
 
const proc: main is func
  begin
    writeln(squaredSum(list1));
    writeln(squaredSum(list2));
  end func;