filter list for range of numbers

Alex Tweedly alex at tweedly.net
Sun Feb 26 17:20:32 EST 2006


dreamscapesoftware.com - List wrote:

>Hello List,
>
>It's been a while since I've posted here, but I've got a question about something that's been bugging me for a long time.  I'm trying to utilize the "filter container with regex" command as opposed to looping through a list as much as possible.  Reason:  it's faster.  
>
That may not always be the case - there were some timing results posted 
that showed that in many cases it was faster to do careful repeat loops 
than regex. Of course it depends on the condition being tested - but

>  repeat for each line tLine in tList
>     if <some condition> then put tLine & CR after tOutput
>  end repeat


is often faster than a regex expression.

>The only problem is that I can't seem to make a Regex that will handle the following...
>
>if (aNumber > lowNumber) and (aNumber < highNumber) then -- Don't remove it from the list
>
>Anyone know how I can achieve this with Regex?  The numbers are like this...
>
>  
>
I think that kind of arithmetic condition is going to be difficult, if 
not impossible, in regex.

I'd try it with a simple repeat loop, and if it isn't fast enough, come 
back to the list with some timings and, if possible, more info (range of 
numbers, size of lists, one number per line?, %age kept vs discarded ??, 
...) and see if there are other ideas.


-- 
Alex Tweedly       http://www.tweedly.net



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 268.1.0/269 - Release Date: 24/02/2006




More information about the use-livecode mailing list