• 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: the Holy Grail of AppleScript lists
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: the Holy Grail of AppleScript lists
      • From: Paul Skinner <email@hidden>
References: 
 >Re: the Holy Grail of AppleScript lists (From: Bill Briggs <email@hidden>)

  • Prev by Date: Re: the Holy Grail of AppleScript lists
  • Next by Date: RE: Why are compiled scripts slower than from Script Editor?
  • Previous by thread: Re: the Holy Grail of AppleScript lists
  • Next by thread: Re: the Holy Grail of AppleScript lists
  • Index(es):
    • Date
    • Thread