Re: the Holy Grail of AppleScript lists
Re: the Holy Grail of AppleScript lists
- Subject: Re: the Holy Grail of AppleScript lists
- From: Paul Berkowitz <email@hidden>
- Date: Wed, 19 Mar 2003 11:20:41 -0800
On 3/19/03 10:41 AM, "Bill Briggs" <email@hidden> wrote:
>
At 1:09 PM -0500 19/03/03, Paul Skinner wrote:
>
> set l to {"3", "a", "C", "c", "B", 2, "A", 1}
>
> repeat 10 times
>
> set l to l & l
>
> end repeat
>
>
>
> -->list of 8291 items.
>
>
Nothing strange about that. You're taking an 8 member list and
>
doubling it 10 times. Each time through the loop the "l" is twice as
>
long as it was before. Do the math. It's (2^10)*8
That's not what he means, Bill. It's this part:
set t to text items of (do shell script ("echo '" & l as text) & "' |
tr '" & delim & "' '\n' | sort -f")
-->list of 8291 items.
l being 8291 items is not the issue. It's t not erroring with a "Stack
overflow" that Paul's talking about. Getting text items, or paragraphs, or
words, of any string where there are more than approximately 4000-4060 such
items always gives the Stack overflow error (or "Out of memory" error).
I can't see how 8291 items is possible either, even if has something to do
with 'do shell script's coercion of LFs to CRs in results, pr whatever.
I confirm it here in SD 3.0.5, AS 1.9.1. But there's something odd: when I
compile it the '\n' compiles to a square. In SE 2.0 beta, it compiles to an
actual linefeed (new line) instead. Interesting.
This also works, and is faster:
set l to {"3", "a", "C", "c", "B", 2, "A", 1}
repeat 10 times
set l to l & l
end repeat
set AppleScript's text item delimiters to {return}
set l2 to (do shell script ("echo '" & l as text) & "' | tr '" & return & "'
'\n' | sort -f")
set AppleScript's text item delimiters to {""}
set t to paragraphs of l2
I wonder what the special case is. I have seen paragraphs wok with over 5000
items occasionally. Maybe it's the shortness (single characters) of the
items. Try this:
set delim to return
set l to {"3333333", "aaaaaaa", "CCCCCCC", "ccccccc", "BBBBBBB", 2222222,
"AAAAAAA", 1111111}
repeat 10 times
set l to l & l
end repeat
set AppleScript's text item delimiters to delim
set t to text items of (do shell script ("echo '" & l as text) & "' | tr '"
& delim & "' '\n' | sort -f")
--> ERROR: An error of type 255 has occurred.
Yup.
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.