Reverse a list

Mike Kerner MikeKerner at roadrunner.com
Fri Feb 13 15:40:16 EST 2015


I must have missed a thread, somewhere.  That would be the thread on how LC
handles loops.

To recap, doing this sort using an sqlite database (insert the values into
a table, then sort the table), was taking me almost 40 seconds.  Then Pete
chimed in and had it working in a couple hundred milliseconds.

The difference?  Pete was using a loop of the form
repeat for each line tLine in theData

and I was doing a
repeat with i = 1 to the number of lines in tData


So, is there some more in-depth discussion of loop forms in LC, somewhere?
I learned something new, today, because 300x faster is a little bit
important.

On Thu, Feb 12, 2015 at 9:35 PM, Kay C Lan <lan.kc.macmail at gmail.com> wrote:

> On Fri, Feb 13, 2015 at 3:04 AM, J. Landman Gay <jacque at hyperactivesw.com>
> wrote:
>
> > On 2/12/2015 12:54 PM, Peter Haworth wrote:
> >
> >>
> >>>  I haven't run any of the LC scripts to do this but if that's true,
> then
> >> they don't achieve the original objective of reversing the list.
> >>
> >
> > I don't think it's true. Using LC scripts, the first and last lines will
> > be terminated by a CR and the line count won't change. The first and last
> > lines will have no values but are still terminated by a CR, which is what
> > determines the count.
> >
>
> Jacques right. I should have actually run the scripts rather than just
> doing it mentally. Because they all add a terminating CR then all is good.
>
> Apologies for confusing the matter.
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



-- 
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."



More information about the use-livecode mailing list