"repeat for each" in reverse order ?

Wouter wouter.abraham at scarlet.be
Mon Jun 27 16:24:31 EDT 2005


Hi,

Using the following to reverse the order of lines of a field  
containing 525605  chars in 14194 lines


reversing by:

on mouseUp
   put fld 1 into x
   put the long seconds into zap
   repeat for each line i in x
     put i&cr before tList
   end repeat
   put the long seconds - zap
   put tList into fld 1
end mouseUp

takes > 60 seconds on a slowbook (G4 400 mhz)


reversing by:

on mouseUp
   put fld 1 into x
   put the long seconds into zap
   split x by return
   get the keys of x
   sort it numeric descending
   repeat for each line i in it
     put x[i]&cr after tList
   end repeat
   put the long seconds - zap
   put tList into fld 1
end mouseUp

yields around 0.413007 seconds on a slowbook (G4 400 mhz)
(which is not too bad)

The amount of chars and lines has a big influence on the speed in the  
first handler,
while in the second handler it has not.

Greetings,
Wouter

On 27 Jun 2005, at 14:40, Dennis Brown wrote:

> The repeat for each only goes in forward sequential order starting  
> at the beginning, except for arrays where the order is indeterminate.
>
> I have requested a sequential access enhancement to allow for  
> constructing this type of looping in a more flexible way (like  
> parallel instantiation, starting at an arbitrary point, and reverse  
> order), to make it possible to wander all over your data  
> sequentially with the speed of the repeat for each method.   
> However, it would be most useful with some improved string  
> delimiter handling.  Bugzilla # 2773
>
> Having a reverse order repeat for each might be up to twice as slow  
> as the forward version depending on how it is implemented, because  
> it has to go backwards to the previous delimiter then forward to  
> pick up the data, though it could pick up the data in reverse order  
> on the way back.  However, even twice as slow would be much faster  
> than any other method.
>
> Dennis



More information about the use-livecode mailing list