@name sum
@kind function

@description
Sum up all values within an array
421147
function sum(input, initial) {

    return (!isArray(input)) ? input :
        input.reduce(function(prev, curr) {
            return prev + curr;
        }, initial || 0);
}
802082
public function sum(?callable $callback = null)
    {
        if ($callback === null) {
            $callback = function ($value, $key) {
                return $value;
            };
        }

        return $this->reduce(function ($total, $value, $key) use ($callback) {
            return $total + $callback($value, $key);
        }, 0);
    }
241088
function $sum(params) {
    if (Array.isArray(params) && params.every(p => typeof p === 'number')) {
        return params.reduce((t, n) => t + n, 0);
    }
    throw new Error('$sum expects an array of number');
}
150041
function aggregate (weights, values) {
  const max = 10 * R.sum(weights);
  const min = 1 * R.sum(weights);
  const sum = R.sum(R.zipWith(R.multiply, weights, values));
  return score(min, max, sum);
}
101899
function(array, fun) {
      return _.reduce(array, function(x, y) {
        return fun(x, y) ? x : y;
      });
    }
1159219
function sum(arr) {
  var len = arr.length;
  var num = 0;
  while (len--) num += Number(arr[len]);
  return num;
}
117434
function reduce(array, callback) {
    var accumulator = null;
    each(array, function(value, index) {
      accumulator = callback(accumulator, value, index, array);
    });
    return accumulator;
  }
881752
function Function_(types) {
    var tuples = Z.reduce (function(tuples, t) {
      tuples.push (['$' + show (tuples.length + 1), K ([]), t]);
      return tuples;
    }, [], types);

    function format(outer, inner) {
      return when (tuples.length !== 2)
                  (parenthesize (outer))
                  (joinWith (outer (', '),
                             Z.map (function(tuple) {
                               return when (tuple[2].type === FUNCTION)
                                           (parenthesize (outer))
                                           (inner (tuple[0])
                                                  (show (tuple[2])));
                             }, init (tuples)))) +
             outer (' -> ') +
             inner ((last (tuples))[0])
                   (show ((last (tuples))[2]));
    }

    return _Type (FUNCTION,
                  '',
                  '',
                  types.length,
                  format,
                  [AnyFunction],
                  K (K (true)),
                  tuples);
  }
142151
def children_sum( self, children,node ):
        """"""
        return sum( [self.value(value,node) for value in children] )
1349317
function sumArray(array) {
  return array.filter(defined).reduce((x, y) => x + y, null);
}
438760
function(index) {
        var sum = 0;

        $.each(this._sizes, function(i, value) {
            if (i < index) {
                sum += value.totalSize;
            }
        });

        return sum;
    }
189880
function summarize(value, counts) {
  const min = counts.min;
  const max = counts.max;
  const num = counts.values.length;
  if (value < min) {
    // do nothing
  } else if (value >= max) {
    counts.values[num - 1] += 1;
  } else {
    const index = Math.floor((value - min) / counts.delta);
    counts.values[index] += 1;
  }
}
938405
function (array) {
                        var total = 0,
                            i;
                        for (i = 0; i < array.length; i += 1) {
                            if (isNaN(array[i])) {
                                total = undefined;
                                break;
                            } else {
                                total += parseFloat(array[i]);
                            }
                        }
                        return total;
                    }
190845
def overall( self, node ):
        """"""
        return sum( [self.value(value,node) for value in self.children(node)] )
870073
function arrays() {
		extend(Array, {
			every: function every(array, fun, thisp) {
				var res = true,
					len = array.length >>> 0;
				for (var i = 0; i < len; i++) {
					if (array[i] !== undefined) {
						if (!fun.call(thisp, array[i], i, array)) {
							res = false;
							break;
						}
					}
				}
				return res;
			},
			forEach: function forEach(array, fun, thisp) {
				var len = array.length >>> 0;
				for (var i = 0; i < len; i++) {
					if (array[i] !== undefined) {
						fun.call(thisp, array[i], i, array);
					}
				}
			},
			map: function map(array, fun, thisp) {
				var m = [],
					len = array.length >>> 0;
				for (var i = 0; i < len; i++) {
					if (array[i] !== undefined) {
						m.push(fun.call(thisp, array[i], i, array));
					}
				}
				return m;
			},
			filter: function map(array, fun, thisp) {
				return Array.prototype.filter.call(array, fun, thisp);
			},
			isArray: function isArray(o) {
				return Object.prototype.toString.call(o) === "[object Array]";
			},
			concat: function(a1, a2) {
				function map(e) {
					return e;
				}
				return this.map(a1, map).concat(this.map(a2, map));
			}
		});
	}
528294
function flattenDown (array, result) {
  for (var i = 0; i < array.length; i++) {
    var value = array[i]

    if (Array.isArray(value)) {
      flattenDown(value, result)
    } else {
      result.push(value)
    }
  }

  return result
}
712063
function arraySum (array, iterate, context) {
  var result = 0
  var toNumber = XEUtils.toNumber
  context = context || this
  baseExports.each(array, iterate ? baseExports.isFunction(iterate) ? function () {
    result += toNumber(iterate.apply(context, arguments))
  } : function (val) {
    result += toNumber(val[iterate])
  } : function (val) {
    result += toNumber(val)
  })
  return result
}