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


def array = 1..3
 
// square via multiplication
def sumSq = array.collect { it * it }.sum()
println sumSq
 
// square via exponentiation
sumSq = array.collect { it ** 2 }.sum()
 
println sumSq