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)


*        Arrays                    04/09/2015
ARRAYS   PROLOG
*        we use TA array with 1 as origin. So TA(1) to TA(20)
*        ta(i)=ta(j)
         L      R1,J               j
         BCTR   R1,0               -1
         SLA    R1,2               r1=(j-1)*4  (*4 by shift left)
         L      R0,TA(R1)          load r0 with ta(j)
         L      R1,I               i
         BCTR   R1,0               -1
         SLA    R1,2               r1=(i-1)*4  (*4 by shift left)
         ST     R0,TA(R1)          store r0 to ta(i)
         EPILOG
* Array of 20 integers (32 bits) (4 bytes)
TA       DS     20F
* Initialized array of 10 integers (32 bits)
TB       DC     10F'0'
* Initialized array of 10 integers (32 bits)
TC       DC     F'1',F'2',F'3',F'4',F'5',F'6',F'7',F'8',F'9',F'10'
* Array of 10 integers (16 bits)
TD       DS     10H
* Array of 10 strings of 8 characters (initialized)
TE       DC     10CL8' '
* Array of 10 double precision floating point reals (64 bits)
TF       DS     10D
*
I        DC     F'2'
J        DC     F'4'
         YREGS
         END    ARRAYS