You are currently viewing the GMLscripts.com static mirror. Forum access and script submissions are not available through this mirror.

Invert GMLscripts.com

ds_list_sum_squares

$$\large \Sigma{x^2}=x_1^2+x_2^2+\cdots+x_n^2$$

ds_list_sum_squares(id)
Returns the sum of squares of all values in a given list.
COPY/// ds_list_sum_squares(id)
//
//  Returns the sum of squares of all values in a given list.
//
//      id          list data structure, real
//
/// GMLscripts.com/license
{
    var i,j,k;
    j = 0;
    k = ds_list_size(argument0);
    for (i=0; i<k; i+=1) j += sqr(ds_list_find_value(argument0, i));
    return j;
}

Contributors: xot

GitHub: View · Commits · Blame · Raw