CFLib.org – Common Function Library Project

ListSum(listStr[, delim])

Last updated September 10, 2001

author

Douglas Williams

Version: 1 | Requires: CF5 | Library: MathLib

Description:
Adds all the numbers in a delimited list returning the sum of the list.

Return Values:
Returns a numeric value.

Example:

<cfset mylist = "5,5,5">

<cfoutput>
The sum of my list is #listSum(mylist)#
</cfoutput>

Parameters:

Name Description Required
listStr Delimited list of numeric values you want to sum. Yes
delim Optional delimiter for the list. The default is the comma. No

Full UDF Source:

/**
 * Adds all the numbers in a delimited list returning the sum of the list.
 * 
 * @param listStr 	 Delimited list of numeric values you want to sum. 
 * @param delim 	 Optional delimiter for the list.  The default is the comma. 
 * @return Returns a numeric value. 
 * @author Douglas Williams (klenzade@i-55.com) 
 * @version 1.0, September 10, 2001 
 */
function listSum(listStr)
{
  var delim = ",";
  if(ArrayLen(Arguments) GTE 2) 
    delim = Arguments[2];
  return ArraySum(ListToArray(listStr, delim));
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson