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


 
Dim A() 'make an array with zero items
 
A=(,) 'make a pointer to array with zero items
 
A=(1,) 'make a pointer to array with one item
 
A()=A 'make a copy of array pointed by A to A()
 
A=A() 'make A a pointer for A()
 
Dim A(10)=1 'redim A() and pass 1 to each item
 
k=lambda m=1->{=m:m++}  ' a lambda function with a closure m
 
Dim B(10)<<k()    'fill B() from 1 to 10
 
A()=B() ' copy B() to A(), A() object stay as is, but new items loaded, so pointer A points to A.
 
A+=100 ' add 100 to each element of A()
 
A(0)+=100 ' add 100 to first element
 
A()=Cons(A,A)
 
Now A and A() prints a 20 item array (Cons() add a list of arrays)
Print A   ' or Print A() print the same
 