Re: can't make { . . . } into an item [error message] deivy's optimized example
Re: can't make { . . . } into an item [error message] deivy's optimized example
- Subject: Re: can't make { . . . } into an item [error message] deivy's optimized example
- From: monk <email@hidden>
- Date: Tue, 17 Jul 2001 19:27:52 -0400
ok, got this one running and the previous problem with repeated listings of
the same items and the list minus 1 in size are gone, it must be something
to do with the random number method - which is immensely faster!
why is the random number method faster than some?
i still get a stack overflow on a large file, will post separately
nice deivy!
h 'monk' elmer
--
http://www.assemblage.org
[ _ o
o o _ -- - - -- > s y m p h o n i c j a m s ]
>
> Ok, based on Michelle's script from yesterday, some lines that I
>
> forgot to put in, and, a clever idea by another scripter, this is a
>
> faster and shorter version of the script I sent you yesterday. Notice
>
> that this script stops only when the original text have all been
>
> mixed. I thought that's what you wanted.
>
>
>
> <script>
>
>
>
> --set _source to open for access (choose file with prompt "choose
>
> source to mix:") with write permission
>
> --set _mix to open for access file (((path to desktop) as string) &
>
> "mixed") with write permission
>
> --set mytext to read _source with delimiters {a,b} -- put you delimiters
>
> here.
>
>
>
> set mytext to "this is the beginning of my text
>
> this is the second line of my text
>
> this is the third line
>
> and finally the forth line " -- this is the equivalent of _source
>
>
>
> set mymix to "" -- this is the equivalent of _mix
>
>
>
> mix(mytext, mymix) -- this mixes the original source into the new mix
>
> --set l to mix(mytext, mymix)
>
> --write l to _mix
>
> --close access _mix
>
>
>
> on mix(mytext, mymix)
>
> set text item delimiters to return -- you want to get the paragraphs
>
> set mymix to text items of mymix
>
> set mytext to text items of mytext -- these two lines coerce
>
> text into list
>
> set pcount to count of text items of mytext
>
> set k to random number from 1 to pcount -- random element
>
> chosen. Michelle Steiner's better line of code
>
> set mymix to mymix & text item k of mytext -- added to _mix
>
> if pcount = 1 then
>
> set mymix to rest of mymix
>
> set mymix to mymix as string
>
> set text item delimiters to "" --default
>
> return mymix
>
> end if
>
> set item k of mytext to {}
>
> set mytext to every string of mytext -- Arthur Knapp's clever idea
>
> mix(mytext, mymix) -- using recurrence. You want to do it
>
> until _source is empty
>
> end mix
>
>
>
> </script>