Reverse a list

BNig bernd.niggemann at uni-wh.de
Mon Feb 16 13:58:40 EST 2015


Hi Peter,

you also might want to check your reverse algorithm on 7.x.x

in my testing Jacque's initial post with little tweaks is as fast as your
code and faster on 7.x.x (tested on 7.0.2 rc2) In my testing it took only
60% of the time compared to yours on 7.x.x
Of course Alex Tweedly's ingenious inverse code leaves everything in the
dust, except on 7.x.x.
----------------------------------------------------------------------
on mouseUp
   put field 1 into tData
   put the milliseconds into t
   get reverseText (tData)
   put the milliseconds - t into field "fRes"
   put it into field 1
end mouseUp

local sNum
function reverseText @pList
   put the number of lines in pList into sNum
   sort lines of pList numeric by reverseSort(each)
   return pList
end reverseText

 private function reverseSort 
   subtract 1 from sNum
   return sNum
end reverseSort
--------------------------------------------------------

private and @ help when the line count is high.

Kind regards

Bernd



--
View this message in context: http://runtime-revolution.278305.n4.nabble.com/Reverse-a-list-tp4688611p4688891.html
Sent from the Revolution - User mailing list archive at Nabble.com.




More information about the use-livecode mailing list