Create a two-dimensional array at runtime: Difference between revisions

Added ZX81 BASIC
(Added Julia language)
(Added ZX81 BASIC)
Line 2,067:
[[0, 0, 0, 0], [0, 0, 1, 0], [0, 0, 0, 0]]
</pre>
 
=={{header|Sinclair ZX81 BASIC}}==
Arrays are indexed from 1; the only limit on their size (which may be an exigent limit) is the available memory. We create an array, write to a randomly selected element and then print it out, and finally use <code>CLEAR</code> to destroy the array (and all the other variables in the program).
<lang basic> 10 PRINT "1ST DIMENSION: ";
20 INPUT D1
30 PRINT D1
40 PRINT "2ND DIMENSION: ";
50 INPUT D2
60 PRINT D2
70 DIM A(D1,D1)
80 PRINT "ARRAY CREATED"
90 LET X=1+INT (D1*RND)
100 LET Y=1+INT (D2*RND)
110 LET A(X,Y)=37
120 PRINT "ITEM ";X;", ";Y;" = ";A(X,Y)
130 CLEAR
140 PRINT "ARRAY DESTROYED"</lang>
{{out}}
<pre>1ST DIMENSION: 11
2ND DIMENSION: 6
ARRAY CREATED
ITEM 7, 4 = 37
ARRAY DESTROYED</pre>
 
=={{header|Smalltalk}}==
519

edits