JB,

You are right in that if I already had the lists setup as keys in an array it could run faster. In that case your example below with a repeat loop runs about the same speed as my original example with a repeat loop. However, using the intersect command instead of a repeat loop would run 4-8 times as fast as either loop version and is fast enough to use for my intended purpose as a direct test to see which blocks of code to execute inside a large loop.

Unfortunately, an array is not an easy thing to use as a constant to check against. I would have to pre-build all my arrays beforehand. If I have to do that, I might just as well build an execution test matrix using the simple lists as parameters. I just wanted to avoid one more level of indirection for the sake of speed (I have so many already). However, I think I understand some new tricks now with your help and from Eric, Alex, and Chris.

Thanks,
Dennis

On Jul 8, 2005, at 4:27 PM, jbv wrote:



Dennis,

Using arrays will always be a speed improvement.

My script creates arrays from your lists of items with loops
just for the purpose of the demonstration. As someone else
suggested, you can use "split" to create your arrays, or better :
drop your lists of items and configure your data as arrays
from the beginning.

Just for the anecdote, I have a cgi script that makes extensive
use of arrays (and only arrays), and it builds 16 pages pdf
files of about 1.4 Mb in roughly 0.1 second, while the previous
version (using items lists) took 3 to 4 seconds...

JB


JB,

It will work, but not a speed improvement.
It will run about 8 times slower than my original example.
It takes Rev a lot of work (time) to create an array element.

Dennis

On Jul 8, 2005, at 2:50 PM, jbv wrote:




Dennis,

Use arrays; Something like :

put "" into myT1
put "" into myT2
repeat for each item i in list1
    put 1 into myT1[i]
end repeat
repeat for each item i in list2
    put 1 into myT2[i]
end repeat

get the keys of myT1
repeat for each line j in it
    if myT2[j]=1 then
        get true
        exit repeat
    end if
end repeat

JB



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,"

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.

Dennis
_______________________________________________
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



_______________________________________________
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



_______________________________________________
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


_______________________________________________
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


_______________________________________________
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

Reply via email to