From d91a53d58008caf9fa9459e3d7474e1c7c3f63d8 Mon Sep 17 00:00:00 2001 From: Siraaj Khandkar Date: Mon, 6 Aug 2012 15:30:18 -0400 Subject: [PATCH] Print char representation of cell state. --- 002/src/life.ml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/002/src/life.ml b/002/src/life.ml index 5e9d6f5..552c1dc 100644 --- a/002/src/life.ml +++ b/002/src/life.ml @@ -6,6 +6,16 @@ let directions = [N; NE; E; SE; S; SW; W; NW] +let char_dead = ' ' +let char_alive = 'o' + + +let char_of_state = function + | 0 -> char_dead + | 1 -> char_alive + | _ -> assert false + + let offset = function (* direction -> x, y *) | N -> 0, -1 @@ -28,7 +38,14 @@ let init_board x y = let print_board board = - Array.iter (fun row -> Array.iter (print_int) row; print_newline ()) board + Array.iter + (fun row -> + Array.iter + (fun state -> print_char (char_of_state state)) + row; + print_newline () + ) + board let new_state = function -- 2.20.1