ARRAY Definitions

Names may be defined as representing arrays or lists of values.  The statement

 

name = ARRAY [ value_1 , value_2 ... value_n ]

 

will define name to be an n-element array of values value_1 ... value_n.

 

In subsequent text, these values may be referenced as

 

name [ index ]

 

The values given in the value list must evaluate to scalar numbers.  They may not contain coordinate or variable dependencies.

 

[Note: In previous versions, the elements of an array were required to be constants computable at the time of reading the script.  In version 5, the elements of an array need only be computable at the time they are used.]

 

Example:

definitions

xc=array(1/3, 2/3, 3/3, 4/3, 5/3)        { a list of X-coordinates }

yc=array(1/3, 2/3, 3/3, 4/3, 5/3)        { a list of Y-coordinates }

...

boundaries

  region 1

    repeat i=1 to 5                { an indexed loop on X-position }

      repeat j=1 to 5                { an indexed loop on Y-position }

start(xc[i]+rad,yc[j])         { an array of circular dots at the }

arc(center=xc[i],yc[j]) angle=360 { ... tabulated coordinates }

close

      endrepeat

    endrepeat

 

This text generates a 5 x 5 array of circles in the domain, all in region 1.

 

See also "Samples | Misc | arrayrepeat.pde".  

 

The SIZEOF function

 

The function SIZEOF may be used to return the number of elements in an ARRAY:

 

number = SIZEOF(arrayname)