]> git.ameliathe1st.gay Git - cells.git/commitdiff
Sérialisation des lignes en vraies lignes
authorAmélia Coutard-Sander <git@ameliathe1st.gay>
Sun, 12 Jan 2025 02:16:17 +0000 (03:16 +0100)
committerAmélia Coutard-Sander <git@ameliathe1st.gay>
Sun, 12 Jan 2025 02:16:17 +0000 (03:16 +0100)
automata/automata.ml

index ca931d14031e31d1d296918c065a479bb0284f8e..5439adffc2d2aff1cd4f47f0147ead3ef266d651 100644 (file)
@@ -133,10 +133,8 @@ let deserialise (type t) (m : (module Automaton with type t = t)) channel =
                                 and y = In_channel.input_line channel |> Option.get |> int_of_string in
                                 let chunk =
                                         Array.init chunk_size (fun _ ->
-                                            Array.init chunk_size (fun _ ->
-                                                (In_channel.input_line channel |> Option.get).[0]
-                                                |> M.of_char
-                                                |> Option.get))
+                                            let l = In_channel.input_line channel |> Option.get in
+                                            Array.init chunk_size (fun i -> l.[i] |> M.of_char |> Option.get))
                                 in
                                 aux (CoordMap.add (x, y) chunk board)
                 in
@@ -150,7 +148,11 @@ let serialise (type t) (m : (module Automaton with type t = t)) (d, board) chann
         CoordMap.iter
           (fun (x, y) chunk ->
             Printf.fprintf channel "%d\n%d\n" x y;
-            Array.iter (Array.iter (fun c -> Printf.fprintf channel "%c\n" (M.to_char c))) chunk)
+            Array.iter
+              (fun l ->
+                Array.iter (fun c -> Printf.fprintf channel "%c" (M.to_char c)) l;
+                Printf.fprintf channel "\n")
+              chunk)
           board
 
 let automata =