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

Buster wouter.abraham at scarlet.be
Tue Nov 8 23:13:16 EST 2005


Hi again,

I was not so a mint condition because of 3 more mistakes of i made/ 
overlooked:



> on mouseup
>
>   put fld "Field 1"  into t1      ### & cr & "ZZZZZZZZZZ" into t1
>
> put fld "Field 2" into t2        ### & cr & "test line" & cr &  
> "ZZZZZZZZZZ" into t2
>
>   put the millisecs into tStart
>
>   put 1 into i2
###  this was the wrong spot to take the num of lines because of a  
possible swap
--  put the number of lines in t2 into limit2
>
>   ### 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
>
>
>
>   sort t1
>
>   sort t2
>
>
>
>   ### swap if necessary
>
>   if line -1 of t1 > line -1 of t2 then
>
>     put t1 into a
>
>     put t2 into t1
>
>     put a into t2
>
>   end if
###
put the number of lines in t2 into limit2

>   split t2 by CR
>
>   put t2[1] into L2
>
>   repeat for each line L1 in t1
>
>     repeat while L2 < L1
>
>  put L2 & cr after t2only
>
>       add 1 to i2
>
>       put t2[i2] into L2
>
>     end repeat
>
>     if L2 = L1 then
>
>       -- put L1 & cr after tBoth
>
>       add 1 to i2
>
>       put t2[i2] into L2
>
>     else
>
>       -- put L1 & cr after t1only
>
>     end if
>
>   end repeat
### if repeat exits on L1 <  L2 condition then L2 was not added to  
the t2only list

if i2 = limit2 then put t2[i2] & cr after t2only
>   if i2 < limit2 then
### this
  --   repeat with i = i2 to limit2-1

### should be

repeat with i = i2 to limit2	

>       put t2[i] & cr after t2only
>
>     end repeat
>
>   end if
>
>   put "loop" && the millisecs - tStart & cr after msg
>
> put t1only & t2only into fld "Field 3"
> end mouseup

Sorry for the inconvenience and

I hope it will be ok by now.

Greetings,

Wouter



More information about the use-livecode mailing list