Re: getting duplicates in a list by item id
Re: getting duplicates in a list by item id
- Subject: Re: getting duplicates in a list by item id
- From: "Mark J. Reed" <email@hidden>
- Date: Sat, 25 Aug 2007 09:02:39 -0400
Put simply, a plain "array" is a list: a sequence of items where a
given item is retrieved by its position in the sequence ("item 4 of
myList" in AppleScript). An "associative array" is an unordered
collection of items where a given item is retrieved by some "key"
value associated with it (hence the name). If AppleScript records
worked with keys that weren't known until runtime, they would qualify.
In a problem like yours, you could keep an associative array whose
keys were the path and whose values the list of positions where that
path was seen. In AS it could just be a list of {path, positionList}
pairs, but then you can't use "contains" or similar to check for a
given path (without knowing its position list).
On 8/25/07, Patrik B. <email@hidden> wrote:
> Hi Mark,
>
> Thanks for your answer and yes I do need the positions. The whole point of
> the positions is that I can do an action with them faster than if I handle
> each one individually.
>
> Example overlay A.pdf on page 1,4,6,7 onto B.pdf. Is WAY faster than
> handling
> each instance i.e. overlay A.pdf onto B.pdf page 1. Then later do A.pdf
> again
> overlay onto page 4 of B.pdf.
>
> The occurence in the list basically stands for a page number in indesign or
> more precisely a page number in a pdf.
>
> By having all the occurences I can handle all identical overlays at once
> rather than linear and thereby speed up the combining process by hours.
>
> Singly 1000 different pdfs combined with another pdf takes about an hour as
> it has to hanlde each instance in a new cycle. But if I can cut down the
> 1000
> steps to about 300 as a lot of paths are duplicate it will run so much
> faster.
>
> Any ideas on how to word this? I am bit hung up on this too.
>
> Patrik
>
> PS: What is an associative array? Is that a javascript term or just another
> term for variable?
>
> Message: 9
> Date: Fri, 24 Aug 2007 19:05:03 -0400
> From: "Mark J. Reed" <email@hidden>
> Subject: Re: getting duplicates in a list by item id
> To: "Applescript Users" <email@hidden>
> Message-ID:
> <email@hidden>
> Content-Type: text/plain; charset=UTF-8
>
> Patrik: do you really need the positions of all the duplicates in the
> list? If you just need a list of the unique names, even with a count
> of how many times each one appears, that's easier to do in AS.
> Keeping track of the actual positions is awkward to do efficiently
> without associative arrays...
>
--
Mark J. Reed <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden