Skip to content
Snippets Groups Projects
Commit 61a9d65d authored by felmer's avatar felmer
Browse files

add sum()

SVN: 14366
parent 13a9b571
No related merge requests found
......@@ -116,6 +116,26 @@ final class StandardFunctions
return condition != null && condition.booleanValue() ? thenValue : elseValue;
}
/**
* Calculates the sum of the specified values.
* Blank strings or <code>null</code> values in the list are ignored.
*
* @throws NumberFormatException if an element can not be parsed as a floating-point number.
* @throws IllegalArgumentException if the list is empty.
*/
public static Double sum(List<Object> values)
{
List<Double> array = toDoubleArray(values);
String functionName = "sum";
assertNotEmpty(array, functionName);
double sum = 0.0;
for (double value : array)
{
sum += value;
}
return sum;
}
/**
* Calculates the mean of the specified values.
* Blank strings or <code>null</code> values in the list are ignored.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment