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


 
bundle Default {
  class Sum {
    function : native : SquaredSum(values : Float[]) ~ Float {
       sum := 0.0;
       for(i := 0 ; i < values->Size()	; i += 1;) {
         sum += (values[i] * values[i]);
       };
 
       return sum;
    }
 
    function : Main(args : String[]) ~ Nil {
       SquaredSum([3.0, 1.0, 4.0, 1.0, 5.0, 9.0])->PrintLine();
     }
  }
}
 