Re: processing time & stack overflow!!!
Re: processing time & stack overflow!!!
- Subject: Re: processing time & stack overflow!!!
- From: Paul Skinner <email@hidden>
- Date: Sat, 01 Sep 2001 00:37:06 -0400
on 8/31/01 11:30 AM, Arthur J Knapp wrote:
>
> Date: Fri, 31 Aug 2001 08:03:05 -0400
>
> From: Victor Yee <email@hidden>
>
> Subject: Re: processing time & stack overflow!!!
>
>
> On Fri, 31 Aug 2001 04:24:15 -0400, monk wrote,
>
>
>
>> can you explain/share to/with us what you did to
>
>> make the script go from an average of 12 minutes to (on my machine) 12
>
>> seconds
>
>
> I basically did what Arthur was telling us to do:
>
>
>
> 1. use his handler ;)
>
> 2. use a reference to the reallyBigList
Snip
>
The randomizing routine is my "port" of an algorithm I found in Robert
>
Sedgwicks's "Algorithms in C". He was showing how to implement hash arrays,
>
and it occured to me that the hashing technique could easily be modified to
>
created "random" index positions.
I've been looking at your NewOrder handler ...
>
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
>
>
Arthur J. Knapp
...one thing I can't figure out.
Why 31415?
piE+4 as integer? ; )
--
Paul Skinner