Re: minimum function?
Re: minimum function?
- Subject: Re: minimum function?
- From: Nigel Garvey <email@hidden>
- Date: Wed, 6 Apr 2005 11:39:32 +0100
Martin Orpen wrote on Wed, 06 Apr 2005 08:44:23 +0100:
> I'd just like to add, for the record, that AS is not fast enough to do this
> sort of task if you are dealing with large lists.
>
> The shell will deliver in less than one second what the cleanest AS script
> will take at least 20 seconds to do:
>
>
> set nList to {}
> repeat 1000 times
> set end of nList to random number from 1 to 99999
[etc.]
What an assertion! :-)
set nList to {}
repeat 1000 times
set end of my nList to random number from 1 to 99999
end repeat
minimum(nList)
on minimum(nList)
script o
property nl : nList
end script
set min to item 1 of o's nl
repeat with i from 2 to (count nList)
set n to item i of o's nl
if n < min then set min to n
end repeat
return min
end minimum
The handler part of this code typically takes about 0.08 seconds to
determine the smallest of 1000 numbers on a 4400 200Mhz 603ev running
AppleScript 1.3.7 in Mac OS 8.6. On a machine that was fast enough to run
OS X, it should - given the same number of numbers - wipe the floor with
any shell script.
NG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden