Back: 4.5 Assignment operations Forward: 4.7 Arithmetic   FastBack: 4. EDL Up: 4. EDL FastForward: 5. Built-in Functions         Top: fsc2 Contents: Table of Contents Index: Index About: About This Document

4.6 Array ranges

Until now we were talking about array indexing as if it would only be possible to index a single element or whole subarrays, i.e. if we have an array defined in the VARIABLES section as

 
k[ 5, 8 ];

then the first element of the first row or the last subarray would be indexed as

 
k[ 1, 1 ]
k[ 5 ]

But it is also possible to parts of array by using range indexing. E.g.

 
k[ 1, 2 : 4 ]

is an one-dimensional array, consisting of the second to the fourth element of the first row of k. And

 
k[ 2 : 4, 7 ]

is also an one-dimensional array of the three elements, having the values k[2,7], k[3,7] and k[4,7]. Finally,

 
k[ 2 : 4, 3 : 7 ]

is a two-dimensional array of rank 3x5. Using

 
k[ 2 : 4, 3 : 7 ] = 1;

would set the third to seventh element of the second to the fourth row of the array k to 1.

Please note: If a range is used were the start index equals the end index a warning will be printed and the result is not an array range anymore but the value of the indexed element. Thus if you have e.g.

 
A[ 3 ] = { 1, 2, 3 };

then the pseudo-range

 
A[ 2 : 2 ]

will be treated as if you had written

 
A[ 2 ]

instead and not as an array with a single element.

Array indexing with ranges can be used on both the left as well as the right hand side of an assignment.


Back: 4.5 Assignment operations Forward: 4.7 Arithmetic   FastBack: 4. EDL Up: 4. EDL FastForward: 5. Built-in Functions

This document was generated by Jens Thoms Toerring on September 6, 2017 using texi2html 1.82.