home
/
code
/
cellular-automata.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Hide (int -> state) mappings.
[cellular-automata.git]
/
polymorphism
/
001
/
src
/
polymorphism.ml
diff --git
a/polymorphism/001/src/polymorphism.ml
b/polymorphism/001/src/polymorphism.ml
index
d292e28
..
5d6fbab
100644
(file)
--- a/
polymorphism/001/src/polymorphism.ml
+++ b/
polymorphism/001/src/polymorphism.ml
@@
-209,7
+209,7
@@
struct
sig
type t = D | A
sig
type t = D | A
- val
of_int : in
t -> t
+ val
random : uni
t -> t
val is_alive : t -> bool
val is_alive : t -> bool
@@
-222,7
+222,8
@@
struct
struct
type t = D | A
struct
type t = D | A
- let of_int = function
+ let random () =
+ match Random.int 2 with
| 0 -> D
| 1 -> A
| _ -> assert false
| 0 -> D
| 1 -> A
| _ -> assert false
@@
-260,8
+261,8
@@
struct
| D -> D
end
| D -> D
end
- let create
()
=
-
Random.int 2 |> State.of_int |>
State.to_cell
+ let create =
+
State.random |-
State.to_cell
let count_of_live =
List.map ~f:State.of_cell_state
let count_of_live =
List.map ~f:State.of_cell_state
@@
-283,7
+284,7
@@
struct
val is_burning : t -> bool
val is_burning : t -> bool
- val
of_int : in
t -> t
+ val
random : uni
t -> t
val to_cell : t -> Cell.t
val to_cell : t -> Cell.t
@@
-299,7
+300,8
@@
struct
| T -> false
| B -> true
| T -> false
| B -> true
- let of_int = function
+ let random () =
+ match Random.int 3 with
| 0 -> E
| 1 -> T
| 2 -> B
| 0 -> E
| 1 -> T
| 2 -> B
@@
-342,8
+344,8
@@
struct
| B, _ -> E
end
| B, _ -> E
end
- let create
()
=
-
Random.int 3 |> State.of_int |>
State.to_cell
+ let create =
+
State.random |-
State.to_cell
let count_of_burning =
List.map ~f:State.of_cell_state
let count_of_burning =
List.map ~f:State.of_cell_state
This page took
0.021397 seconds
and
4
git commands to generate.