ranging lists

Ron rbarber at yhb.att.ne.jp
Wed Jan 29 07:02:01 EST 2003


Hi

Here's a challenge that I've been working on optimizing today and thought I
would ask the list for help in making it good transcript.

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)

I need to take item 1 of list 2 and see if it is > 1 and <10. If yes, then
keep the item, if not, delete it. Then I need to take the next item of list
2 and see if it falls within the range 1 10, and so on.

Brute force can iterate each item of list 2 and compare it with each line of
list 1 but I think it can be more elegant by noting when the item in line 2
excedes the upper limit of the range and then move on to the next range. The
faster the better.

thanks for any suggestions on approaches, it doesn't have to be completed
code.
Ron




More information about the use-livecode mailing list