Skip to content

Instantly share code, notes, and snippets.

@ppshein
Created January 14, 2011 03:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ppshein/779135 to your computer and use it in GitHub Desktop.
Save ppshein/779135 to your computer and use it in GitHub Desktop.
<cffunction name="ListGetDifferent" output="yes">
<cfargument name="mainList" required="Yes" />
<cfargument name="compareList" required="Yes" />
<cfargument name="CompareType" required="Yes" default="Same" />
<cfset ReturnList = "" />
<cfif CompareType EQ "Same">
<cfloop list="#mainList#" index="i">
<cfif ListFindNoCase(compareList,i)>
<cfset ReturnList = ListAppend(ReturnList,i) />
</cfif>
</cfloop>
<cfelse>
<cfloop list="#mainList#" index="i">
<cfif NOT ListFindNoCase(compareList,i)>
<cfset ReturnList = ListAppend(ReturnList,i) />
</cfif>
</cfloop>
</cfif>
<cfreturn ReturnList />
</cffunction>
@ppshein
Copy link
Author

ppshein commented Jan 14, 2011

Usage of UDF is as follow.

ListGetDifferent("1,2,3,4,5", "1,3,5", "Same")

ListGetDifferent("1,2,3,4,5", "1,3,5", Differ")#

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment