Reverse a list

Jerry Jensen jhj at jhj.com
Mon Feb 9 23:23:42 CET 2015


Just a thought, untested.

Change the first two executable lines to:
split p by cr
put the number of lines of the keys of p into tNumElems

That way instead of having to spin through the entire data twice counting lines, once for the number of lines and again for split,
it would only spin all the way through once (during split) and then a much faster run counting keys.

This probably won't make a measurable difference if its only executed once, unless the data is really large.

.Jerry

On Feb 9, 2015, at 2:04 PM, Mark Wieder <mwieder at ahsoftware.net> wrote:

> Sorry - got one line out of place. Here ya go.
> Still the fastest yet.
> 
> function arevers p
>   local t
>   local tNumElems
> 
>   put the number of lines in p into tNumElems
>   split p by cr
>   put empty into t
>   repeat for each line l in p
>      put p[tNumElems] & cr after t
>      subtract 1 from tNumElems
>   end repeat
>   return t
> end arevers
> 
> -- 
> Mark Wieder
> ahsoftware at gmail.com
> 
> 
> 
> _______________________________________________
> 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




More information about the use-livecode mailing list