– Common Function Library Project

listsAreDistinct(list1, list2[, delim1][, delim2])

Last updated June 25, 2003


Nathan Dintenfass

Version: 1 | Requires: CF5 | Library: StrLib

Given two lists, returns a boolean value telling you whether both lists have entirely different elements. In other words, no element in list 1 exists in list 2 and vice versa. The comparison is case insensitive.

Return Values:


	list1 = "a,b,c,d,e,f";
	list2 = "g,h,i,j";
	list3 = "K+A+I";

Is list1 (<em>#list1#</em>) distinct from list2 (<em>#list2#</em>)?
<br />
<br /><br />

Is list1 (<em>#list1#</em>) distinct from list3 (<em>#list3#</em>)?
<br />
<br /><br />

Is list3 (<em>#list3#</em>) distinct from list2 (<em>#list2#</em>)?
<br />


Name Description Required
list1 The first list Yes
list2 The second list Yes
delim1 The delimiter of the first list (default is comma) No
delim2 The delimiter of the second list (default is comma) No

Full UDF Source:

 * Tells whether two lists have entirely distinct elements
 * @param list1 	 The first list (Required)
 * @param list2 	 The second list (Required)
 * @param delim1 	 The delimiter of the first list (default is comma) (Optional)
 * @param delim2 	 The delimiter of the second list (default is comma) (Optional)
 * @return boolean 
 * @author Nathan Dintenfass ( 
 * @version 1, June 25, 2003 
function listsAreDistinct(list1,list2){
	var delim1 = ",";
	var delim2 = ",";
	var ii = 0;
	var array = "";
	//deal with the optional delimiter arguments
	switch(arrayLen(arguments)) {
		case 3:
			delim1 = arguments[3];
		case 4:
			delim1 = arguments[3];
			delim2 = arguments[4];
	//make list1 into an array for easy looping
	array = listToArray(list1,delim1);
	//loop through list1 checking for any matches in list2
	for(ii = 1; ii LTE arrayLen(array); ii = ii + 1){
		//if this element exists in list 2, return false
			return false;
	//if we've gotten this far, the lists are distinct
	return true;
blog comments powered by Disqus


Latest Additions

Kevin Cotton added
May 5, 2016

Raymond Camden added
April 25, 2016

Chris Wigginton added
January 18, 2016

Gary Stanton added
November 19, 2015

Sebastiaan Naafs - van Dijk added
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson