Whatever message this page gives is out now! Go check it out!
arraySum(array [, parallel] [, maxThreadCount]) |
Parameter | Description |
array | (Required) Name of an array. |
ignoreEmpty | (Optional) Boolean (true/false) value denoting whether to ignore empty (Null or "") values in the array while adding the elements. False by default. |
parallel | True if you want to enable parallel programming. |
maxThreadCount | The number of threads the function can execute. The number of threads must be between 1-50. If the value exceeds 50, there is an exception. |
<cfscript>
myArray=[921,22,133,40,345,58,-6];
WriteOutput("Sum of values in myArray is:");
WriteOutput(ArraySum(myArray) & "|"); // returns sum of values in myArray
myNewArray=[];
WriteOutput("Sum of values in myNewArray is:");
WriteOutput(ArraySum(myNewArray)); //returns zero since myNewArray is empty
</cfscript><cfscript>
myarray=ArrayNew(1);
myarray=[-23,56,97,javacast("null",""),"",1,23];
sum=arraysum(myarray,true); //ignoreEmpty=true
writeoutput(sum);
</cfscript><cfscript>
for(i=1;i<=100000;i++){
if(i === 4500)
arr[i]=0;
else
arr[i]=i*2;
}
sum= arr.map(function(item){
return item/2;
},true,20).sum(false,true,10)
writeoutput(sum & "<br>");
sum = arraysum(array=arr,ignoreempty=true,parallel=true,maxthreadcount=10)
writeoutput(sum & "<br>");
sum1 = arraysum(arr,false,true,10)
writeoutput(sum1 & "<br>");
</cfscript>