Simple array question

Mark Brownell gizmotron at earthlink.net
Thu Sep 30 23:25:57 EDT 2004


On Thursday, September 30, 2004, at 05:48 PM, Alex Tweedly wrote:

>> At 15:50 30/09/2004 -0700, Mark Brownell wrote:
>> Maybe by using a faster repeat loop and a simpler append technique.
>>
>> put "" into tResults
>> put 1 into i
>> repeat
>>     put x[i] & return after tResults
>>     if x[i] = empty then exit repeat
>>     add 1 to i
>>  end repeat
>>  put tResults into field 2
>>
>> This is not sorting, I guess.
>
> Takes 25 ticks - much better.
>
> But there's no reason not to use a loop counter - that should be 
> faster than an explicit increment and test for empty.
>   repeat with i = 1 to m
>     put x[i] & return after tResults
>   end repeat
>   put tResults into field 2
>
> takes only 15 ticks for 11,000 elements.
>
> -- Alex.


What do you get for this? I'm not sure I did this right. [untested]

  repeat for each element i in x
       put i & return after tResults
   end repeat
   put tResults into field 2

Mark




More information about the use-livecode mailing list