Re: processing time & stack overflow
Re: processing time & stack overflow
- Subject: Re: processing time & stack overflow
- From: Arthur J Knapp <email@hidden>
- Date: Wed, 29 Aug 2001 11:43:43 -0400
>
Date: Tue, 28 Aug 2001 18:26:11 -0400
>
From: Victor Yee <email@hidden>
>
Subject: Re: processing time & stack overflow
>
On Tue, 28 Aug 2001 11:05:04 -0400, Arthur J Knapp wrote,
>
>
> on NewOrder(lst)
>
> set {s1, s2, len} to ,
>
> {random number from 1 to 100000, 31415, lst's length}
>
> repeat with i from 1 to len
>
> set {j, s1} to {(s1 mod len) + 1, (s1 * s2) mod len}
>
> set {lst's item i, lst's item j} to ,
>
> {lst's item j, lst's item i}
>
> end repeat
>
> end NewOrder
>
>
Thanks Arthur :)
>
>
After playing with this 'cross cutting' script for a while, I would have to
>
conclude that having AppleScript very large lists isn't a good idea.
Speed improvments with large lists can often be achived by using the
"a ref to" operator:
-- bigList to a big list
--
-- It is also a top-level variable, as opposed to a local variable,
-- which is important for using the "a ref to" operator
--
set refList to a reference to bigList
NewOrder(refList)
bigList --> randomized
>
on _switchWords(a, b)
>
tell application "Tex-Edit Plus"
>
tell window 1
>
set x to text of word a
>
set contents of word a to text of word b
>
set contents of word b to x
This is a little less readable, but for repeated calls could
be a little faster:
set {contents of word a, contents of word b} to ,
{text of word b, text of word a}
Arthur J. Knapp
http://www.stellarvisions.com
mailto:email@hidden
Hey, check out:
http://www.latenightsw.com/freeware/JavaScriptOSA/