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

Content added Content deleted
(adding gap)
Line 482: Line 482:
arr.[0,0] <- 42
arr.[0,0] <- 42
printfn "%d" arr.[0,0]</lang>
printfn "%d" arr.[0,0]</lang>
=={{header|GAP}}==
<lang gap># Creating an array of 0
a := NullMat(2, 2);
# [ [ 0, 0 ], [ 0, 0 ] ]

# Some assignments
a[1][1] := 4;
a[1][2] := 5;
a[2][1] := 3;
a[2][2] := 4;

a
# [ [ 4, 5 ], [ 3, 4 ] ]

Determinant(a);
# 1</lang>

=={{header|Go}}==
=={{header|Go}}==
Arrays in Go are only one dimensional. Code below show the obvious way of composing a 2d array as an array of arrays that can be indexed as a[r][c].
Arrays in Go are only one dimensional. Code below show the obvious way of composing a 2d array as an array of arrays that can be indexed as a[r][c].