Relative Speed of different loop structures. [was Finding non-common elements]

Alex Tweedly alex at tweedly.net
Tue Nov 8 09:22:16 EST 2005


Buster wrote:

>
> On 06 Nov 2005, at 03:48, Alex Tweedly wrote:
>
> -snip completely-
>
>
> Hi,
>
> I was wondering why your code wasn't working correctly.
> Because I liked your idea and wanted to test its speed, I delved in  
> and found 2 problems
>   - using the <  (or >) operator in this case must be done on  
> literals and not on numerics.
>      --> a step must be added to make sure both lists are literals
>   - to prevent an endless loop:  last line of t2 >= last line of t1
>
> Here it is in working/mint condition:
>
<snip>

>   ### making sure the strings are  non numerics
>   if char -1 of t1 is not cr then put cr after t1
>   if char -1 of t2 is not cr then put cr after t2
>   replace cr with " a"&cr in t1
>   replace cr with " a"&cr in t2
>
Duh. I knew there had to be some easy way to avoid the numeric 
comparisons - but just couldn't think of it.

Blindingly obvious now I see it. Thank you !

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



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.12.8/162 - Release Date: 05/11/2005




More information about the use-livecode mailing list