Dennis Brown wrote:
Hello clever Rev programmers,
I have a simple question or maybe it is a simple challenge.
I have two lists of integers. The list are not long, perhaps 5 to 50
items e.g.:
list1="310,423,522,211,107,340,"
lis2="311,312,313,318,320,323,325,330,333,337,340,"
Are the items in each list known to be unique or not ?
i.e. could I have list1 = "310,423,310" ?
I want to find if any of the items in list1 have a match in list2.
I know I could do it with a repeat, something like this:
get false
repeat for each item theItem in list1
if theItem is not among the items of list2 then next repeat
get true
exit repeat
end repeat
I was wondering if it could be done faster without a repeat through
some Rev trick.
For data samples that small, I doubt if there will be anything faster.
For data large enough to overcome the cost of some set-up time (say
upwards of 20,000 items in each set), you might get faster with either
an array/intersect based scheme, or simply by sorting and stepwise
comparing each one. The array method is especially appealing if there
can be repeated entries.
For *large* data sets, you might be best with binary-search comparing
of sorted lists - especially if you can arrange things such that the
lists are sorted ahead of time.
And for 5 to 50 items - who cares : the simple solution doesn't take
long enough to warrant any time spent optimizing it :-)
--
Alex Tweedly http://www.tweedly.net
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.8.10/43 - Release Date: 06/07/2005
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution