RosettaCodeData/Task/Multi-dimensional-array/BBC-BASIC/multi-dimensional-array-2.b...

16 lines
523 B
Plaintext

10 REM Create a four-dimensional array (with 120 elements in all):
20 DIM array(1, 2, 3, 4)
30
40 REM Initialise a specific row of the array:
50 array(1, 0, 3, 0 TO 4) = 9, 8, 7, 6, 5
60
70 REM Copy one row into another row:
80 array(1, 1, 1, 0 TO 4) = array(1, 0, 3, 0 TO 4)
90
100 REM Pass a slice to a function:
110 PRINT ' "The sum of the row is ";FNsumarray(array(1, 1, 1, 0 TO 4))
120 END
130
140 REM Function to sum the elements of an array:
150 DEF FNsumarray(a()) = SUM(a())