Construction

Arrays of primitive values can be constructed in several ways. A literal value is written as follows:

    a = [1, 2, 3, 4, 5]

Arrays can also be constructed by autorange expressions. The expression

    begin n end m step k

constructs an array starting with n and proceeding in increments of k until m is reached. More precisely, it constructs

    [n, n+k, n+2k, ..., n+rk] 

where r is the largest integer such that n+rk <= m.

The expression

    begin n count c step k

constructs an array of c elements beginning with n and proceeding in increments of k, that is,

    [n, n+k, n+2k, ..., n+(c-1)k].

For example,

    begin 10 end 15 step 2

and

    begin 10 count 3 step 2

both construct the array:

    [10, 12, 14].

The third way to construct an array is to use the split function, which divides a string into array elements at whitespace. Quoted elements keep embedded whitespace and strip the quotes upon placement into the array. For example, on UNIX machines:

    split(‘ls‘)

returns an array of the files in the current directory.