problem with counting words
dunbarx at aol.com
dunbarx at aol.com
Tue Oct 14 16:10:23 EDT 2014
Richard.
Right, and I am sure you know this, but it was never particularly a speed issue,rather more a mental and organizational one, that would be even more opaque if you had, say a handful of nested delimiters instead of just two.
Craig
-----Original Message-----
From: Richard Gaskin <ambassador at fourthworld.com>
To: use-livecode <use-livecode at lists.runrev.com>
Sent: Tue, Oct 14, 2014 3:46 pm
Subject: Re: problem with counting words
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
_______________________________________________
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