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

m
Added the Sidef language
m (→‎{{header|Perl 6}}: output slightly different now)
m (Added the Sidef language)
Line 1,716:
Give me the numer of columns: 7
The number at place [1, 1] is 3
</pre>
 
=={{header|Sidef}}==
<lang ruby>func make_matrix(x, y) {
y.of { x.of(0) };
}
 
var y = Sys.scanln("rows: ").to_i;
var x = Sys.scanln("cols: ").to_i;
 
var matrix = make_matrix(x, y); # create the matrix
matrix[y/2][x/2] = 1; # write something inside it
say matrix; # display the matrix</lang>
{{out}}
<pre>
rows: 3
cols: 4
[[0, 0, 0, 0], [0, 0, 1, 0], [0, 0, 0, 0]]
</pre>
 
2,756

edits