Print char representation of cell state.
authorSiraaj Khandkar <siraaj@khandkar.net>
Mon, 6 Aug 2012 19:30:18 +0000 (15:30 -0400)
committerSiraaj Khandkar <siraaj@khandkar.net>
Mon, 6 Aug 2012 19:30:18 +0000 (15:30 -0400)
002/src/life.ml

index 5e9d6f5..552c1dc 100644 (file)
@@ -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
This page took 0.031929 seconds and 4 git commands to generate.