I'm a newbie at OCaml. And when I do some coding using array in Ocaml I come to a problem I can't understand.
Here is the code:
let a = Array.create 5 (Array.create 5 0);
a.(0).(1) <- 1
I just want to assign 1 to a[0][1] but then things happened: all the element in the first colummn has been assigned. That is, a[0][1], a[1][1], a[2][1], a[3][1] and a[4][1] are all equal to 1 after the code above executed.
If I create the array using:
Array.make_matrix 5 5 0
everything is fine.
My environment:
Ubuntu 13.10
Ocaml 4.01.0
open Core.Std