On Wednesday, January 29, 2003, at 04:57 AM, Ron wrote:
Arrays are very fast. I didn't benchmark it, but see if something like this is faster than what you are using now:
I have 2 lists. I need to check whether the values of list 2 fall within the
range of the values of list 1. eg.
list 1
1 10
20 25
45 55
list 2
1,3,12,23,34,45,52,78
function checkRanges
put fld 1 into theRanges -- this is List 1
repeat for each line l in theRanges -- make an array
put word 1 of l + 1 into theStart
put word 2 of l - 1 into theStop
repeat until theStart > theStop
put theStart into theRangeArray[theStart]
add 1 to theStart
end repeat
end repeat
-- now check the items in list 2 against the array:
put fld 2 into theList
repeat for each item i in theList
put (theRangeArray[i] <> empty) & comma after theResults
end repeat
return theResults
end checkRanges
This returns a list of booleans corresponding to each item in List 2, indicating whether each item is within range or not.
Creating the initial array probably takes the most time (but it is still very fast.) If this is something you will use repeatedly, build the array only once and store it in a global variable so you don't have to rebuild it each time you want to use it.
--
Jacqueline Landman Gay | [EMAIL PROTECTED]
HyperActive Software | http://www.hyperactivesw.com
_______________________________________________
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution
