From 097a500b7df1b0d2233a4edb99973bee942814f9 Mon Sep 17 00:00:00 2001 From: kevin Date: Tue, 24 Nov 2020 15:00:43 +0100 Subject: [PATCH] correction MSgfile --- medium_project/Makefile | 2 +- medium_project/src/MSftest.ml | 2 +- medium_project/src/MSgfile.ml | 14 ++++++-------- medium_project/src/MSgfile.mli | 4 ++-- medium_project/src/moneySharing.mli | 2 +- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/medium_project/Makefile b/medium_project/Makefile index bcf222f..466c808 100644 --- a/medium_project/Makefile +++ b/medium_project/Makefile @@ -18,4 +18,4 @@ demo: build clean: -rm -rf _build/ - -rm ftest.native + -rm MSftest.native diff --git a/medium_project/src/MSftest.ml b/medium_project/src/MSftest.ml index 5df431c..fbba757 100644 --- a/medium_project/src/MSftest.ml +++ b/medium_project/src/MSftest.ml @@ -31,7 +31,7 @@ let () = (* Open file *) let (graph, l_id) = from_file infile in - let initGraph = g_to_float graph in + let initGraph = graph in (* Rewrite the graph that has been read. *) diff --git a/medium_project/src/MSgfile.ml b/medium_project/src/MSgfile.ml index 3c73b0c..751f4dc 100644 --- a/medium_project/src/MSgfile.ml +++ b/medium_project/src/MSgfile.ml @@ -38,8 +38,6 @@ let write_file path graph l_id= fprintf ff "\n%% End of reimbursements\n" ; - - close_out ff ; () @@ -51,15 +49,15 @@ let read_comment graph line l_id= (* Reads a line with a user. *) let read_user id graph l_id line = - try Scanf.sscanf line "u %s" (fun user l_id-> ((init_node graph user id), l_id) ) + try Scanf.sscanf line "u %s" (fun user -> init_node graph user id l_id ) with e -> Printf.printf "Cannot read node in line - %s:\n%s\n%!" (Printexc.to_string e) line ; failwith "from_file" (* Reads a line with a payement. *) -let read_payement graph line l_id= +let read_payement graph l_id line = try Scanf.sscanf line "p %s %s %f" - (fun u l_u label -> ((paiement graph u (String.split_on_char ',' l_u) label), l_id)) + (fun user l_user label -> paiement graph user (String.split_on_char ',' l_user) label l_id) with e -> Printf.printf "Cannot read arc in line - %s:\n%s\n%!" (Printexc.to_string e) line ; failwith "from_file" @@ -81,10 +79,10 @@ let from_file path = (* Ignore empty lines *) if line = "" then (n, (graph, l_id)) - (* The first character of a line determines its content : n or e. *) + (* The first character of a line determines its content : u or p. *) else match line.[0] with - | 'u' -> (n+1, (read_user n graph l_id line)) - | 'p' -> (n, read_payement graph line l_id) + | 'u' -> (n+1, read_user n graph l_id line) + | 'p' -> (n, read_payement graph l_id line) (* It should be a comment, otherwise we complain. *) | _ -> (n, read_comment graph line l_id) diff --git a/medium_project/src/MSgfile.mli b/medium_project/src/MSgfile.mli index c67744d..b69b937 100644 --- a/medium_project/src/MSgfile.mli +++ b/medium_project/src/MSgfile.mli @@ -2,9 +2,9 @@ open Graph type path = string -val from_file: path -> (string graph * (string * id) list) +val from_file: path -> (float graph * (string * id) list) -val write_file: path -> string graph -> (string * id) list-> unit +val write_file: path -> string graph -> (string * id) list -> unit val export: path -> string graph -> unit diff --git a/medium_project/src/moneySharing.mli b/medium_project/src/moneySharing.mli index 7971efb..0275c5c 100644 --- a/medium_project/src/moneySharing.mli +++ b/medium_project/src/moneySharing.mli @@ -2,7 +2,7 @@ open Graph val paiement: float graph -> string -> string list -> float -> (string * id) list -> (float graph * (string * id) list) -val init_node: float graph -> string ->id -> (string * id) list-> (float graph * (string * id) list) +val init_node: float graph -> string -> id -> (string * id) list-> (float graph * (string * id) list) val get_id: string -> (string * id) list -> id