CFLib.org – Common Function Library Project

listParseWithFunction(list, funcitonName[, delimiters])

Last updated February 3, 2006

author

Kit Brandner

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Parse a list of values with the specified function. Returns a list of the values returned by the function itself. Only UDFs are supported, but a UDF could be used to wrap a built-in function.

Return Values:
Returns a list.

Example:

<cfscript>
function x(y) { return y & "  foo "; }
</cfscript>

<cfoutput>#listParseWithFunction("a,b,c", x)#</cfoutput>

Parameters:

Name Description Required
list List to use. Yes
funcitonName The UDF. Yes
delimiters List delimiter. Defaults to a comma. No

Full UDF Source:

/**
 * Parse a list of values with the specified function.
 * 
 * @param list 	 List to use. (Required)
 * @param funcitonName 	 The UDF. (Required)
 * @param delimiters 	 List delimiter. Defaults to a comma. (Optional)
 * @return Returns a list. 
 * @author Kit Brandner (orchaen@gmail.com) 
 * @version 1, February 3, 2006 
 */
function listParseWithFunction(list,functionName) {
	var delimiters = ",";
	var returnList = "";
	var i = "";
	if(arrayLen(Arguments) gt 2) delimiters = Arguments[2];

	for(i=1;i lte listLen(list, delimiters); i=i+1) returnList = listAppend(returnList, functionName(listGetAt(list, i)), delimiters);
	return returnList;
}
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