From 47c9d6963d399bc3fac7d39616cf26066311cc29 Mon Sep 17 00:00:00 2001 From: Siraaj Khandkar Date: Mon, 30 Sep 2013 23:51:01 -0400 Subject: [PATCH] Cleaner composition. --- polymorphism/001/src/polymorphism.ml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/polymorphism/001/src/polymorphism.ml b/polymorphism/001/src/polymorphism.ml index 8d85a0e..0444595 100644 --- a/polymorphism/001/src/polymorphism.ml +++ b/polymorphism/001/src/polymorphism.ml @@ -263,9 +263,10 @@ struct let create () = Random.int 2 |> State.of_int |> State.to_cell - let count_of_live neighbors = - neighbors |> List.map ~f:(State.of_cell_state |- State.to_int) - |> List.fold_left ~init:0 ~f:(+) + let count_of_live = + List.map ~f:State.of_cell_state + |- List.map ~f:State.to_int + |- List.fold_left ~f:(+) ~init:0 let transition ~self ~neighbors = self |> State.of_cell_state @@ -351,11 +352,11 @@ struct let create () = Random.int 3 |> State.of_int |> State.to_cell - let count_of_burning neighbors = - neighbors |> List.map ~f:State.of_cell_state - |> List.filter ~f:State.is_burning - |> List.map ~f:State.to_int - |> List.fold_left ~init:0 ~f:(+) + let count_of_burning = + List.map ~f:State.of_cell_state + |- List.filter ~f:State.is_burning + |- List.map ~f:State.to_int + |- List.fold_left ~f:(+) ~init:0 let transition ~self ~neighbors = self |> State.of_cell_state -- 2.20.1