listSome

This function calls a given closure/function with every element in a given string list and returns true, if one of the closure calls returns true.

listSome(list, closure [, delimiter] [, includeEmptyFields] [, multiCharacterDelimiter] [, parallel] [, maxThreads]) → returns boolean

Member Function Syntax

list.listSome(closure [, delimiter] [, includeEmptyFields] [, multiCharacterDelimiter] [, parallel] [, maxThreads])

This function requires Lucee.  Not supported on Adobe ColdFusion, etc.

Argument Reference

list string
Required

string list to iterate

Alias: string

closure function
Required

function/closure that implements the following constructor [function(any value, numeric index,string list, string delimiter):boolean].

Alias: function, callback, udf

Callback parameters:

  • value*any : current value from the list
  • index*numeric : position in the list
  • list*string : string list to iterate
  • delimiter*string : delimiter used to separate the string list

delimiter string
Default: ,

delimiter used to separate the string list

includeEmptyFields boolean
Default: false

include empty fields or not

multiCharacterDelimiter boolean
Default: true

specifying whether the delimiters parameter specifies a multi-character delimiter. If this parameter is true, the delimiters parameter must specify a single delimiter consisting of multiple characters. This parameter enables the ListToArray function to convert a list to an array of color names

parallel boolean
Default: false

execute closures parallel

maxThreads numeric
Default: 20

maximum number of threads executed, ignored when argument "parallel" is set to false

Links more information about listSome

Examples
Sample code invoking the listSome function

Take a string list and see if some elements match a given predicate.

var fruitList = arrayToList(["apple", "mango", "orange", "pear"], ",");
writeOutput(listSome(fruitList, function(fruit) {
	return findNoCase("n", fruit);
}, ","));

Expected Result: true

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub