Re: Determining item number matching "x" in a list
Re: Determining item number matching "x" in a list
- Subject: Re: Determining item number matching "x" in a list
- From: Emmanuel <email@hidden>
- Date: Fri, 14 Mar 2003 17:01:05 +0100
At 3:36 PM +0000 14/03/03, John Delacour wrote:
This script writes 32000 random ascii characters to a file. It then
loops through every character (line) and reports the index in the
list of every "a" it finds.
The second loop takes about half a second on my machine, or 19
seconds if I loop though a million items.
do shell script "perl -e '
$f = qq~/tmp/junk.txt~ ;
open F, qq~>$f~ ;
for (1..32000) {
$_ = 33 + int rand(223) ; print F chr() .$/ }'"
do shell script "perl -e '
$f = qq~/tmp/junk.txt~ ; open F, qq~$f~ ;
for (<F>) {
$i++ ;
/a/ and print qq~$i$/~ }'"
This script writes 32000 random ASCII characters to a variable. It
then loops through every character and reports the index of every "a"
it finds.
The second loop takes about a 1/50 second on my machine (G3 Pismo 400
Mhz), or 14 seconds if I loop through a million items.
set s to ""
repeat 32000 times
set s to s & (ASCII character of (random number from 10 to 253))
end repeat
find text "a" in s with all occurrences
Emmanuel
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.