• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: processing time & stack overflow
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: processing time & stack overflow


  • Subject: Re: processing time & stack overflow
  • From: monk <email@hidden>
  • Date: Wed, 29 Aug 2001 05:13:24 -0400

i'll take a try with this and see how i come out!

>> Date: Tue, 28 Aug 2001 11:20:31 +1000
>> Subject: Re: processing time & stack overflow
>> From: Timothy Bates <email@hidden>
>
>> to randomize(TheList)
>> repeat with i from length of TheList to 1 by -1
>> set current_item to some item of TheList's items 1 thru i
>> tell TheList -- exchange item current_item with item i
>> set temp to contents of item i
>> set item i to contents of current_item
>> set current_item to temp
>> end tell
>> end repeat
>> return TheList
>> end randomize
>
> I'm afraid that I haven't been following this thread, so I'm not sure
> what is needed here, but I noticed that the above handler does not
> randomize in the sense that each item is preserved and occurs in a
> new place:
>
> set myList to {"a", "b", "c", "d"}
>
> randomize(myList)
> myList --> {"a", "a", "b", "b"}
>
> randomize(myList)
> myList --> {"a", "a", "a", "a"}
>
> randomize(myList)
> myList --> {"a", "a", "c", "c"}
>
>
> I suspect that the above are not the desired results.
>
> This is a modification of a script that I posted a few months ago, it
> uses only one osax call:
>
>
> 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
>
> set lst to {"a", "b", "c", "d"}
>
> NewOrder(lst)
> lst --> {"b", "c", "d", "a"}
>
> NewOrder(lst)
> lst --> {"c", "a", "b", "d"}
>
> NewOrder(lst)
> lst --> {"c", "b", "a", "d"}
>
>
> The problem with using "some item" is that you can't keep track
> of the index location from which the item came from. "some item"
> only returns the value of that item.
>
> P.S. My handler still needs to be more thoroughly tested...
>
>
>
> Arthur J. Knapp
> http://www.stellarvisions.com
> mailto:email@hidden
>
> Hey, check out:
> http://www.LateNightSW.com
> _______________________________________________
> applescript-users mailing list
> email@hidden
> http://www.lists.apple.com/mailman/listinfo/applescript-users

h 'monk' elmer
--
            
http://www.assemblage.org
            


  • Prev by Date: Re: PLEASE HELP ... Photoshop action scripting
  • Next by Date: Re: processing time & stack overflow
  • Previous by thread: Re: processing time & stack overflow
  • Next by thread: Re: processing time & stack overflow
  • Index(es):
    • Date
    • Thread