Re: list of lists as arrays - creating?
Re: list of lists as arrays - creating?
- Subject: Re: list of lists as arrays - creating?
- From: Arthur J Knapp <email@hidden>
- Date: Wed, 03 Apr 2002 14:19:58 -0500
>
Subject: Re: list of lists as arrays - creating?
>
Date: Wed, 3 Apr 2002 07:45:39 +0100
>
From: Nigel Garvey <email@hidden>
>
Arthur J Knapp wrote on Tue, 02 Apr 2002 12:44:21 -0500:
>
> on newArrayXY(x, y)
>
> script ArrayXY
>
> property thisArray : {}
>
> on GetAt(x, y)
>
> return my thisArray's item x's item y
>
> end GetAt
>
> on SetAt(x, y, v)
>
> set my thisArray's item x's item y to v
>
> end SetAt
>
> end script
>
>
>
> repeat (x) times
>
> set ArrayXY's thisArray's end to {}
>
> repeat (y) times
>
> set ArrayXY's thisArray's item -1's end to 0
>
> end repeat
>
> end repeat
>
>
>
> return ArrayXY
>
Nice one, Arthur. :-)
>
May I suggest the following speed tweek for the nested repeat?
No.
>
... It makes
>
the inner loop about four times as fast (AS 1.6):
Oh, uh, well, OK then. ;-)
>
repeat (x) times
>
set ArrayXY's thisArray's end to {}
>
tell the result
>
repeat (y) times
>
set its end to 0
Great stuff, Nigel. :)
>
Alternatively, the telling can be arranged like this:
>
>
repeat (x) times
>
tell {}
>
set ArrayXY's thisArray's end to it
>
repeat (y) times
>
set its end to 0
How telling. ;-)
Of course, I was just trying to keep it simple. The best solution
would be to give the script object it's own method for sizing itself,
(which would then allow for the faster "my" syntax).
>
> on newArrayXY(x, y)
>
> script ArrayXY
>
> property thisArray : {}
on DimArray( xLength, yLength ) --> set array dimensions
...
{ Arthur J. Knapp, of <
http://www.STELLARViSIONs.com>
<
mailto:email@hidden>
try
<
http://www2.linkedresources.com/tools/carthandle.html>
on error number -128
end try
}
_______________________________________________
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.