Re: two lists - matching any element
That's what I realized after I sent it. One of these days I've got to learn to read everything... Anyhow the .removeAll() method approach is very interesting. That's going into my toolbox. regards, larry >Hey Larry, had the same thought as me ;) However, containsAll() isn't >what he's after - he needs containsAny() which doesn't exist. Shame >really. > >Dominic > >2008/5/22 Larry Lyons <[EMAIL PROTECTED]>: >> ~| 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:305909 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: two lists - matching any element
On Thu, May 22, 2008 at 12:14 PM, Dominic Watson < [EMAIL PROTECTED]> wrote: > Hey Larry, had the same thought as me ;) However, containsAll() isn't > what he's after - he needs containsAny() which doesn't exist. Shame > really. > > Dominic > > 2008/5/22 Larry Lyons <[EMAIL PROTECTED]>: > > Jeff, > > > > Take advantage of CF sitting on top of Java. Convert the lists to arrays > using listToArray. Then use the containsAll() method of java list to see if > all the elements of one array are present in another array. Using your > example, > > > > > > > > > > > > > > > > > > > > > > hth, > > > > larry > > > > > >> 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:305906 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: two lists - matching any element
Hey Larry, had the same thought as me ;) However, containsAll() isn't what he's after - he needs containsAny() which doesn't exist. Shame really. Dominic 2008/5/22 Larry Lyons <[EMAIL PROTECTED]>: > Jeff, > > Take advantage of CF sitting on top of Java. Convert the lists to arrays > using listToArray. Then use the containsAll() method of java list to see if > all the elements of one array are present in another array. Using your > example, > > > > > > > > > > > hth, > > larry > > >> 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:305896 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: two lists - matching any element
Jeff, Take advantage of CF sitting on top of Java. Convert the lists to arrays using listToArray. Then use the containsAll() method of java list to see if all the elements of one array are present in another array. Using your example, hth, larry > 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:305893 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: two lists - matching any element
>@Dominic.. Short and sweet.. Exactly what I was lookign for.. although I'm not >sure yet if it breaks out as early as I would like.. but I haven't explorer >the UDF code yet. Either way, the correct results and short code is perfect! >Appreciate it. Yeh, it's clearly not the most efficient for large lists (though large lists just aren't efficient). After some testing, the following method seemed just about the most efficient in terms of proccesing time: Pretty obvious really. You'd probably want a NoCase version too. Dominic -- Blog it up: http://fusion.dominicwatson.co.uk ~| 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:305891 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: two lists - matching any element
> Try this (just wrote it). It uses the removeAll method of the array > object and is very little code: It actually could be slimmer than that because the removeAll method returns true if the array is changed after operation. Here it is again but with delimiter option support (and slimmer): function ListContainsAny(list1, list2){ var delim1 = iif(ArrayLen(arguments) GTE 3, DE(arguments[3]), DE(',')); var delim2 = iif(ArrayLen(arguments) GTE 4, DE(arguments[4]), DE(',')); var aOne = ListToArray(arguments.list1, delim1); var aTwo = ListToArray(arguments.list2, delim2); return aOne.removeAll(aTwo); } -- Blog it up: http://fusion.dominicwatson.co.uk ~| 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:305887 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: two lists - matching any element
Wow.. very quick responses! Thanks to both of you. @Bobby.. THanks for pointing that UDF out. Not sure if it is exactly what I need, but with modifications and thinking about it a bit, that would definitely get me started. @Dominic.. Short and sweet.. Exactly what I was lookign for.. although I'm not sure yet if it breaks out as early as I would like.. but I haven't explorer the UDF code yet. Either way, the correct results and short code is perfect! Appreciate it. Thanks again to both of you.. Great great stuff. Jeff ~| 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:305886 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: two lists - matching any element
Try this (just wrote it). It uses the removeAll method of the array object and is very little code: function ListContainsAny(list1, list2){ var aOne = ListToArray(arguments.list1); var originalCount = ArrayLen(aOne); aOne.removeAll(ListToArray(arguments.list2)); return ArrayLen(aOne) NEQ originalCount; } 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
RE: two lists - matching any element
http://www.cflib.org/udf.cfm?id=149&enable=1 ..:.:.:.:.:.:.:.:.:.:.:.:. Bobby Hartsfield http://acoderslife.com http://cf4em.com -Original Message- From: Jeff Becker [mailto:[EMAIL PROTECTED] Sent: Thursday, May 22, 2008 10:33 AM To: CF-Talk Subject: two lists - matching any element 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:305883 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
two lists - matching any element
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:305882 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4