NYGiantsFan
asked on
comparing two lists in coldfusion
Hi,
I have two lists in coldfusion. I want to see if list one have the values of list two, if so, I want them removed.
How do I do?
thanks.
I have two lists in coldfusion. I want to see if list one have the values of list two, if so, I want them removed.
How do I do?
thanks.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
<cfset List1="1,2,3,4,5,6,7,8,9">
<cfset List2="1,10,11,12,1,4">
<cfset List3 "">
<cfloop list="#List1#" index="l_key">
<cfif not ListContainsNoCase(List2,k ey)>
<cfset List3=ListAppend(List3,key )>
</cfif>
</cfloop>
<cfdump var="#List3#">
<cfset List2="1,10,11,12,1,4">
<cfset List3 "">
<cfloop list="#List1#" index="l_key">
<cfif not ListContainsNoCase(List2,k
<cfset List3=ListAppend(List3,key
</cfif>
</cfloop>
<cfdump var="#List3#">
hey lhp2000... thats another take on it ;) creating a new list..
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
I guess I should have tested it BEFORE posting :)
This one actually works..
This one actually works..
<!--- returns all elements of list one minus the elements of list two --->
<!--- #listMinus("1,2,3,3,3,4,5", "3,5,6")# returns 1,2,4 --->
<cffunction name="listMinus" access="public" output="false">
<cfargument name="listOne" required="true" default="" />
<cfargument name="ListTwo" required="false" default="" />
<cfset var result = "">
<cfset var kk = "">
<cfloop index="kk" list="#arguments.listOne#">
<cfif listFindNoCase(arguments.listTwo,kk) eq 0>
<cfset result = listAppend(result,kk)>
</cfif>
</cfloop>
<cfreturn result>
</cffunction>
<cfoutput>#listMinus("1,2,3,3,3,4,5", "3,5,6")#</cfoutput>
@NYGiantsFan ? ping...
timeout... tahahha
ASKER
Thanks, although I figured it out on my own. Thanks all.
https://www.experts-exchange.com/questions/22573882/Compare-List-elements-to-each-other.html