ranging lists

depstein at att.net depstein at att.net
Wed Jan 29 23:21:01 EST 2003


Since you're dealing with integers, you could run each line of list 1 through 
a function like

function numberSeries x,y
-- returns space-delimited list of all integers from x to y

to build an expanded version of list 1 that explicitly lists all possible 
matching numbers in each range.  Then send each item n in list 2 to a 
function:

function whichRange n,expandedList
set wholeMatches to true
get wordOffset(n,expandedList)
if it = 0 then return 0
return the number of lines in word 1 to it of expandedList

I suspect this will be faster than running each of your 2000 numbers 
through a series of comparisons.

David Epstein


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

> >List 1 may have up to 60 different ranges, one range per line.
> >List 2 may have over 2000 items. (these are line numbers of a text 
database)



More information about the use-livecode mailing list