Most efficient way to check if two lists

2002-05-21 Thread Won Lee

Hello,

Need to find out which way is the most efficient way to see if a value in 
list A is a value in list B.

List A = 1,2,3  VALID ListMatch
List B = 2,3,4

List A = 1,2,3  VALID ListMatch
List B = 1,4,6

List A = 1,2,3  NOT VALID ListMatch
List B = 7,4,6


As long as it has single matching values it is valid.

__
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Most efficient way to check if two lists

2002-05-21 Thread Cravens, Billy

The most obvious method is to loop and use listFind()

cfset match = no
cfloop index=i list=#list1#
cfif listFind(list2,i)
cfset match = yes
cfbreak
/cfif
/cfloop

---
Billy Cravens
 

-Original Message-
From: Won Lee [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, May 21, 2002 12:57 PM
To: CF-Talk
Subject: Most efficient way to check if two lists

Hello,

Need to find out which way is the most efficient way to see if a value
in 
list A is a value in list B.

List A = 1,2,3  VALID ListMatch
List B = 2,3,4

List A = 1,2,3  VALID ListMatch
List B = 1,4,6

List A = 1,2,3  NOT VALID ListMatch
List B = 7,4,6


As long as it has single matching values it is valid.


__
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



Re: Most efficient way to check if two lists

2002-05-21 Thread Sharon Diorio

cfset match = 0
cfloop list=#listA# index=i
cfif listFind(listB, i)
cfset match = 1
/cfif
/cfloop

HTH!

Sharon DiOrio

- Original Message - 
From: Won Lee [EMAIL PROTECTED]
To: CF-Talk [EMAIL PROTECTED]
Sent: Tuesday, May 21, 2002 1:57 PM
Subject: Most efficient way to check if two lists


 Hello,
 
 Need to find out which way is the most efficient way to see if a value in
 list A is a value in list B.
 
 List A = 1,2,3 VALID ListMatch
 List B = 2,3,4
 
 List A = 1,2,3 VALID ListMatch
 List B = 1,4,6
 
 List A = 1,2,3 NOT VALID ListMatch
 List B = 7,4,6
 
 
 As long as it has single matching values it is valid.
 
 
__
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Most efficient way to check if two lists

2002-05-21 Thread Rob Baxter

Most efficient probably depends on how the list is organized, but check out
cflib and the ListInCommon or ListUnion udfs. You could probably modify one
of them to just return true as soon as a match was found instead of building
the entire union.

/rob

-Original Message-
From: Won Lee [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 21, 2002 1:57 PM
To: CF-Talk
Subject: Most efficient way to check if two lists


Hello,

Need to find out which way is the most efficient way to see if a value in
list A is a value in list B.

List A = 1,2,3  VALID ListMatch
List B = 2,3,4

List A = 1,2,3  VALID ListMatch
List B = 1,4,6

List A = 1,2,3  NOT VALID ListMatch
List B = 7,4,6


As long as it has single matching values it is valid.


__
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Most efficient way to check if two lists

2002-05-21 Thread Van Vliet, Scott

I build a UDF to do just that

cfscript
function compareLists(listIn,listToCheck) {
delim = ,; // Default
if (ArrayLen(arguments) GT 2) { delim = arguments[3]; }
listIn = delim  listin  delim;
regExp = delim  ReplaceNoCase(listToCheck, delim, delim  | 
delim, ALL)  delim;
return REFindNoCase(regExp, listIn);
}
/cfscript

Works like a charm :) HTH

cfset listA = 1,2,3
cfset listB = 2,7,5
cfif compareLists(listA,listB)
..
/cfif

Note that you can optionally specify the delimeter:

cfset listA = 1$2$3
cfset listB = 2$7$5
cfif compareLists(listA,listB,$)
..
/cfif

Enjoy!

--
Scott Van Vliet
Sempra Energy
555 W. 5th St., 21st Floor
Los Angeles, CA 90013
Tel  213.244.5205
Email  [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]


Hello Stupid, and welcome to your crappy computer.
- Strong Bad, HomestarRunner.com






 -Original Message-
 From: Won Lee [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, May 21, 2002 10:57 AM
 To: CF-Talk
 Subject: Most efficient way to check if two lists
 
 
 Hello,
 
 Need to find out which way is the most efficient way to see 
 if a value in 
 list A is a value in list B.
 
 List A = 1,2,3VALID ListMatch
 List B = 2,3,4
 
 List A = 1,2,3VALID ListMatch
 List B = 1,4,6
 
 List A = 1,2,3NOT VALID ListMatch
 List B = 7,4,6
 
 
 As long as it has single matching values it is valid.
 
 
__
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Most efficient way to check if two lists

2002-05-21 Thread Won Lee

Thanks.
By the time I got this email I just edited the listcompare UDF at cflib.org.


At 11:43 AM 5/21/2002 -0700, you wrote:
I build a UDF to do just that

cfscript
function compareLists(listIn,listToCheck) {
 delim = ,; // Default
 if (ArrayLen(arguments) GT 2) { delim = arguments[3]; }
 listIn = delim  listin  delim;
 regExp = delim  ReplaceNoCase(listToCheck, delim, delim  | 
delim, ALL)  delim;
 return REFindNoCase(regExp, listIn);
}
/cfscript

Works like a charm :) HTH

cfset listA = 1,2,3
cfset listB = 2,7,5
cfif compareLists(listA,listB)
..
/cfif

Note that you can optionally specify the delimeter:

cfset listA = 1$2$3
cfset listB = 2$7$5
cfif compareLists(listA,listB,$)
..
/cfif

Enjoy!

--
Scott Van Vliet
Sempra Energy
555 W. 5th St., 21st Floor
Los Angeles, CA 90013
Tel  213.244.5205
Email  [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]


Hello Stupid, and welcome to your crappy computer.
- Strong Bad, HomestarRunner.com






  -Original Message-
  From: Won Lee [mailto:[EMAIL PROTECTED]]
  Sent: Tuesday, May 21, 2002 10:57 AM
  To: CF-Talk
  Subject: Most efficient way to check if two lists
 
 
  Hello,
 
  Need to find out which way is the most efficient way to see
  if a value in
  list A is a value in list B.
 
  List A = 1,2,3VALID ListMatch
  List B = 2,3,4
 
  List A = 1,2,3VALID ListMatch
  List B = 1,4,6
 
  List A = 1,2,3NOT VALID ListMatch
  List B = 7,4,6
 
 
  As long as it has single matching values it is valid.
 
 

__
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists