Re: minimum function?
Re: minimum function?
- Subject: Re: minimum function?
- From: has <email@hidden>
- Date: Wed, 6 Apr 2005 19:19:47 +0100
Martin Orpen wrote:
> > And what, pray tell, is Mr. Garvey so infamous for that "doing a
> > Garvey" has entered into the AS users' lexicon? For that matter,
> > what do you mean by "script a" and "script o"??
>
>Google it for yourself! Who is the top of the "script o" heap?
IIRC it was Emmanuel Levy who came up with this particular kludge. Awkward and ugly, but it does the job for defeating one of AppleScript's stupider (mis-)features.
>Definition of the term: somebody who wipes that self-satisfied smile from
>your face by posting a script that is both simpler, more efficient - and
>yet, at the same time, more cunning - than the one that you posted less than
>twelve hours before.
I shouldn't boast too much if I were you: your script uses a woefully inefficient and wasteful algorithm that'd make even a junior-high CS student cringe.
>Anyhow, back to scripting - I'm crying foul because I think that we should
>compare like with like.
I'm not sure what comparing one crappy algorithm against another crappy algorithm proves, other than you don't know much about algorithms. A well-written and optimised vanilla AS min() handler will be more efficient - and therefore generally faster - than an inefficient sort-based shell script, and can be stuffed into an external library where no-one need ever worry about how un-beautiful it looks.
>My script is sorting the whole bloody list and then grabbing the first item.
And whose fault is this, hmmm?
>How long would it take a vanilla AppleScript to sort the whole list?
About 10x longer than the Unix sort, using a properly-optimised AppleScript quicksort algorithm [1]. BTW, while a pure vanilla AS sort isn't as fast as using the Unix sort command, it's far more robust and flexible. There's so many ways a hackish shell script-based sort can go wrong in AS that it's completely unsuitable for anything except a very narrow range of problems.
has
[1] e.g. <http://applemods.sourceforge.net/mods/Data/List.php>
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
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