Re: Sifting a list sans loop
Re: Sifting a list sans loop
- Subject: Re: Sifting a list sans loop
- From: Arthur J Knapp <email@hidden>
- Date: Mon, 28 Jan 2002 14:20:35 -0500
>
Date: Mon, 28 Jan 2002 08:12:43 -0800
>
Subject: Re: Sifting a list sans loop
>
From: Paul Berkowitz <email@hidden>
>
On 1/28/02 7:15 AM, "Arthur J Knapp" <email@hidden> wrote:
>
>
> This works for almost any AppleScript type-class. One word
>
> of caution: for a list of 5000 items, you might run into
>
> AppleScript's upper limit for returning a list, approx 4050
>
> some items or so:
>
Ah. What's this, then? I think I (or rather a user) may have run into this.
>
Will it apply, say, to lists of lists? I.e., to a list of 1000 sub-lists
>
each with 50 items?
No.
>
... That would explain something I've been mulling over.
>
I've been considering whether I should convert each of those 1000 sublists
>
to tab-delimited strings and write the string to a line of text file one at
>
a time as I go along, rather than convert the entire master-list to text at
>
the very end and write it as one text variable as I've been doing.
There are no known problems with creating very large lists, or even
large lists of sublists, or with coercing large lists to strings.
The "get-list limit", (for lack of a better name), occurs when
AppleScript is asked to create a "new" list, whose total length
is greater than approx 4000 items. Consider:
set myList to {}
repeat (10000) times
set myList's end to "a"
end repeat
myList --> An AppleScript list has no practical limits, it can
-- be as large as a "long" integer, or up to available
-- memory, whichever comes first.
set thisList to myList --> No problem setting a list to another
-- variable, (data-sharing).
set thatList to every item of myList
--
--> error "Memory overflow..."
--
-- By asking for "every" item, we are telling AS to create a new
-- list whose length is greater approx. 4000. This is where the
-- problems occur.
set bigString to myList as string --> No problem with list to string
set characterList to every character of bigString
--
-- error...
--
set textitemList to every text item of bigString
--
-- error...
--
In both of the above cases, we are coercing a string to a list
of string-elements. This is NOT a string-coercion problem, however,
it is occuring because AppleScript doesn't like to create a list
that large, (with a single command, coercion, etc.).
The one exception, though, is list concatenation. AppleScript
doesn't seem to have any problems doing this:
set bigList to myList & myList --> REALLY big list
{ Arthur J. Knapp, of <
http://www.STELLARViSIONs.com>
<
mailto:email@hidden>
try
<
http://maccentral.macworld.com/columns/briggs.shtml>
on error number -128
end try
}