Try this (just wrote it). It uses the removeAll method of the array
object and is very little code:
<cfscript>
function ListContainsAny(list1, list2){
var aOne = ListToArray(arguments.list1);
var originalCount = ArrayLen(aOne);
aOne.removeAll(ListToArray(arguments.list2));
return ArrayLen(aOne) NEQ originalCount;
}
</cfscript>
For info on removeAll and others, check out this blog post:
http://coldfused.blogspot.com/2007/01/extend-cf-native-objects-harnessing.html
HTH
Dominic
2008/5/22 Jeff Becker <[EMAIL PROTECTED]>:
> Hi folks,
>
> I'm not 100% sure on all the "list" functions in CF.. so I'm hoping this
> group can give me a little guidance.
>
> Ideally, I'm looking for a UDF that takes in two LISTS and returns a BOOLEAN.
> True if ANY element in list 2 is in list 1. False if NO element in list 2
> is in list 1.
>
> I tried to search cflib.org and also looked at the avail functions for lists.
> It needs to be optimized, so ideally breaking out of the UDF once the first
> match is found.
>
> EXAMPLES:
> list1 = 5,8,2,20
> list2 = 4,6
> result = FALSE
>
> list1 = 700,300,400,1100,2200
> list2 = 300,400
> result = TRUE, but breaking out of comparisions after first find (300)
>
> list1 = 1
> list2 = 3,4,6,1,2,11,100,101,102,103,104
> result = TRUE, but breaking out of comparisions after element 4 = (1)
>
>
> appreciate any guidance!
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:305884
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4