CFLib.org – Common Function Library Project

listParseWithFunction(list, funcitonName[, delimiters])

Last updated February 03, 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;
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson