Reverse a list

Mike Kerner MikeKerner at roadrunner.com
Mon Feb 16 11:55:50 EST 2015


According to LC, we're dealing with somewhere bewtween nlog(n) and n on the
one side and n^2 on the other, which is about as far apart as we can get.

On Mon, Feb 16, 2015 at 11:09 AM, Bob Sneidar <bobsneidar at iotecdigital.com>
wrote:

> Ah. Because the keys of an array are effectively a system of pointers in
> themselves. It might actually be slightly quicker, since the array has
> already been created, while the For Each will have to create the pointers
> on the fly at the start of the loop. I’d be curious to find out how much
> time the pointer creation takes as opposed to the actual loop time.
>
> Bob S
>
>
> On Feb 15, 2015, at 04:56 , Dave Cragg <dave.cragg at lacscentre.co.uk
> <mailto:dave.cragg at lacscentre.co.uk>> wrote:
>
> The advantage of "repeat for each" is when iterating over chunks in a
> string. (repeat for each line/item/word) In this case, we’re iterating over
> array elements, and so there is no advantage. If you look back at my
> earlier version which iterated through array elements from last to first,
> you’ll see it is basically doing the same as your reverseSort, and the
> times are also the same.
>
> Cheers
> Dave
>
> _______________________________________________
> 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