Accessing parts of arrays
Michael J. Lew
michaell at unimelb.edu.au
Wed Sep 29 19:22:59 EDT 2004
Maybe you could use the intersect command to split out subarrays.
Otherwise, remember that you can easily combing an array by comma and
then use the average(item 1 to 4 of x) approach.
At 6:23 PM -0400 29/9/04, Greg wrote:
>
>To: Revolution <use-revolution at lists.runrev.com>
>Message-ID: <9B897E58-1231-11D9-AE17-000D9350C9C2 at videotron.ca>
>Content-Type: text/plain; charset=US-ASCII; format=flowed
>
>Hello everyone,
>
>In doing some statistical work, it occurred to me that Revolution's
>arrays would be greatly enhanced if we could access sub-arrays just
>like we can with itemized and line-delimited lists.
>
>For example, in a comma-delimited list of the natural numbers, 1 to 10,
>we can compute the average of any subset of the numbers using the
>average() function:
>
>put "1,2,3,4,5,6,7,8,9,10" into x
>put average(item 1 to 4 of x) && \
>average(x) && \
>average(item 1 to 8 of x) --yields 2.5, 5.5 and 4.5.
>
>But as far as I know, we cannot refer to element 1 to 4 of array x, and
>we can only take the average of all the values in x to get 5.5 as
>below.
>
>multiply t by 0
>repeat 10 times
>add 1 to t
>put t into x[t]
>end repeat
>put average(x) -- yields 5.5
>
> Greg
--
Michael J. Lew
Senior Lecturer
Department of Pharmacology
The University of Melbourne
Parkville 3010
Victoria
Australia
Phone +613 8344 8304
**
New email address: michaell at unimelb.edu.au
**
More information about the use-livecode
mailing list