Re: An alternative to "sort" & "uniq"
Re: An alternative to "sort" & "uniq"
- Subject: Re: An alternative to "sort" & "uniq"
- From: Martin Orpen <email@hidden>
- Date: Mon, 18 Apr 2005 15:39:46 +0100
Title: Re: An alternative to "sort" & "uniq"
on 18/4/05 14:03, Gary (Lists) at email@hidden wrote:
> The appleMods 'List' library has over two dozen (well, 25 ;) commands for
> dealing with lists. Some of those are related to rapid-fire sorting of
> lists [1] and many more to further kinds of list processing.
>
> The Library is sufficiently well-thought to provide a mechanism for passing
> list items off to any user-defined callback handlers for even more
> fine-tuned processing (I am thinking about uniqueness here, where you could
> shuffle new items onto a new list object, or already-existing items onto
> another, or whatever -- including processing mathematically, for min/max.)
Thanks for the links and the information about the mods.
I already have a couple of additions that handle lists and they do a very good job - but I'm keen to try and extend AS via the exposed bits of Cocoa that you can find if you dig around the OS.
The benefits being that these functions are both fast and free and that there are even more features exposed in Tiger.
Hopefully Apple will also have left an empty AppleScript Studio app or some other utility that can be used to access the APIs so that there is no need to build one on a client machine or install Daniel's AppleScriptKit :-)
I like it because you can just slap stuff together to bypass any missing features in vanilla AS – so, if I want to time my script without any additions or using Smile etc I can knock up a quick timer in about 2 minutes:
set theList to {}
set a to getTimeInterval()
repeat 10000 times
set end of theList to random number from 1 to 10000
end repeat
set b to getTimeInterval()
set foo to procArray(theList)
set c to getTimeInterval()
set d to "List build: " & b - a & " List sort: " & c - b
on procArray(myArray)
tell application "AppleScriptKit"
set theArray to call method "arrayWithArray:" of class "NSArray" with parameter myArray
set sArray to call method "distinct" of myArray
end tell
end procArray
on getTimeInterval()
tell application "AppleScriptKit"
set t to call method "timeIntervalSinceReferenceDate" of class "NSDate"
end tell
return t as inches as string
end getTimeInterval
--> ”List build: 25.069247990847 List sort: 1.99908798933”
And I did check the 10,000 item list and it was sorted - pretty good for less than two seconds :-)
Apologies for the inches as string my 2 minutes didn’t include time to work out how to do the maths using obj-c...
--
Martin Orpen
_______________________________________________
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