val get : 'a t -> row:int -> col:int -> 'a
- val set : 'a t -> row:int -> col:int -> data:'a -> unit
-
val map : 'a t -> f:('a -> 'b) -> 'b t
val mapi : 'a t -> f:(row:int -> col:int -> data:'a -> 'b) -> 'b t
let get t ~row ~col =
t.(row).(col)
-
- let set t ~row ~col ~data =
- t.(row).(col) <- data
end
module type CELL = sig
type t
- val init : unit -> t
+ val create : unit -> t
val to_string : t -> string
| D -> " "
| A -> "o"
- let init () =
+ let create () =
Random.int 2 |> of_int
let state = to_int
let main rows cols () =
Random.self_init ();
- let grid = Matrix.create ~rows ~cols ~data:() |> Matrix.map ~f:Conway.init in
+ let grid = Matrix.create ~rows ~cols ~data:() |> Matrix.map ~f:Conway.create in
Matrix.print grid ~to_string:Conway.to_string