home
/
code
/
cellular-automata.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3ccae1a
)
Print char representation of cell state.
author
Siraaj Khandkar
<siraaj@khandkar.net>
Mon, 6 Aug 2012 19:30:18 +0000
(15:30 -0400)
committer
Siraaj Khandkar
<siraaj@khandkar.net>
Mon, 6 Aug 2012 19:30:18 +0000
(15:30 -0400)
002/src/life.ml
patch
|
blob
|
blame
|
history
diff --git
a/002/src/life.ml
b/002/src/life.ml
index
5e9d6f5
..
552c1dc
100644
(file)
--- a/
002/src/life.ml
+++ b/
002/src/life.ml
@@
-6,6
+6,16
@@
let directions =
[N; NE; E; SE; S; SW; W; NW]
[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
let offset = function
(* direction -> x, y *)
| N -> 0, -1
@@
-28,7
+38,14
@@
let init_board x y =
let print_board board =
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
let new_state = function
This page took
0.017875 seconds
and
4
git commands to generate.