This task is about arrays.

For hashes or associative arrays, please see Creating an Associative Array.

For a definition and in-depth discussion of what an array is, see Array.



Task

Show basic array syntax in your language.

Basically, create an array, assign a value to it, and retrieve an element   (if available, show both fixed-length arrays and
dynamic arrays, pushing a value into it).

Please discuss at Village Pump:   Arrays.

Please merge code in from these obsolete tasks:

   Creating an Array
   Assigning Values to an Array
   Retrieving an Element of an Array


Related tasks

   Collections
   Creating an Associative Array
   Two-dimensional array (runtime)


begin
    % declare an array %
    integer array a ( 1 :: 10 );
    % set the values %
    for i := 1 until 10 do a( i ) := i;
    % change the 3rd element %
    a( 3 ) := 27;
    % display the 4th element %
    write( a( 4 ) ); % would show 4 %
    % arrays with sizes not known at compile-time must be created in inner-blocks or procedures %
    begin
        integer array b ( a( 3 ) - 2 :: a( 3 ) ); % b has bounds 25 :: 27 %
        for i := a( 3 ) - 2 until a( 3 ) do b( i ) := i
    end
    % arrays cannot be part of records and cannot be returned by procecures though they can be passed %
    % as parameters to procedures                                                                     %
    % multi-dimension arrays are supported                                                            %
end.