problem with counting words
Richard Gaskin
ambassador at fourthworld.com
Tue Oct 14 15:45:29 EDT 2014
FWIW, changing the itemdel takes only about 0.00012 ms on a relatively
slow (2.16GHz) Mac, and about a third as long (0.000043 ms) on my custom
Linux box (3.0 GHz).
on mouseup
put 100000 into n
--
put the millisecs into t
repeat n
get 1+1
end repeat
put the millisecs - t into t1
--
put the millisecs into t
repeat n
get 1+1
set the itemdel to "#"
end repeat
put the millisecs - t into t2
--
put (t2-t1)/n
end mouseup
If that would be fast enough for your needs, you could write a function
that takes any number of item number/delimiter pairs as arguments,
following the data itself:
on mouseUp
put 1000 into n
put "aaa,bbb,ccc#ddd#eee#fff,ggg,hhh" into tSomeData
--
put the millisecs into t
repeat n
get nDepth(tSomeData, 3, comma, 2, "#" )
end repeat
put the millisecs - t into t1
put t1/n &cr& it
end mouseUp
function nDepth
get param(1)
repeat with i = 2 to paramCount() step 2
set the itemDel to param(i+1)
get item param(i) of it
end repeat
return it
end nDepth
On my old Mac that takes only about 0.005 ms per call.
--
Richard Gaskin
Fourth World Systems
Software Design and Development for the Desktop, Mobile, and the Web
____________________________________________________________________
Ambassador at FourthWorld.com http://www.FourthWorld.com
More information about the use-livecode
mailing list