From 6929ab225e497370fe6e47f220084699cf036dc4 Mon Sep 17 00:00:00 2001 From: Erwan Jahier <erwan.jahier@univ-grenoble-alpes.fr> Date: Sun, 10 Mar 2019 20:40:14 +0100 Subject: [PATCH] Remove in Algo.varT the type N (that was meant for Natural number) and reuse it for Neighbor, which make the naming more consistent. --- bin/process.ml | 3 +-- bin/stringOf.ml | 3 +-- lib/algo/algo.ml | 14 ++++++-------- lib/algo/algo.mli | 8 ++++---- test/bfs-spanning-tree/p.ml | 4 ++-- 5 files changed, 14 insertions(+), 18 deletions(-) diff --git a/bin/process.ml b/bin/process.ml index cfd73e5f..9cd50914 100644 --- a/bin/process.ml +++ b/bin/process.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 09/03/2019 (at 11:41) by Erwan Jahier> *) +(* Time-stamp: <modified the 10/03/2019 (at 20:35) by Erwan Jahier> *) type t = { pid : string; @@ -29,7 +29,6 @@ let (make: Topology.node -> t) = user_init_env nl v | Some x -> ( match List.assoc_opt v vars with - | Some(Algo.Neighbor) | Some(Algo.It) | Some(Algo.Nt) -> I (int_of_string x) | Some(Algo.Bt) -> B (bool_of_string x) diff --git a/bin/stringOf.ml b/bin/stringOf.ml index 1515200f..228fa5a5 100644 --- a/bin/stringOf.ml +++ b/bin/stringOf.ml @@ -2,11 +2,10 @@ open Algo let (algo_varT: Algo.varT -> string) = function | It -> "int" - | Nt -> "pos_int" | Ft -> "float" | Bt -> "bool" | Et i -> Printf.sprintf "enum(%d)" i - | Neighbor -> "Neighbor" + | Nt -> "Neighbor" let (algo_vars : Algo.vars -> string) = fun vars -> String.concat "," (List.map (fun (n,t) -> Printf.sprintf "%s:%s" n (algo_varT t)) vars) diff --git a/lib/algo/algo.ml b/lib/algo/algo.ml index 3f4b8f43..3e461696 100644 --- a/lib/algo/algo.ml +++ b/lib/algo/algo.ml @@ -1,7 +1,7 @@ -(* Time-stamp: <modified the 09/03/2019 (at 15:04) by Erwan Jahier> *) +(* Time-stamp: <modified the 10/03/2019 (at 20:35) by Erwan Jahier> *) (** Process programmer API *) -type varT = It | Nt | Ft | Bt | Et of int | Neighbor +type varT = It | Nt | Ft | Bt | Et of int type action = string (* juste un label *) type value = I of int | F of float | B of bool | S of string | N of int type local_env = string -> value @@ -35,12 +35,11 @@ let tbls = { let verbose_level = ref 0 let vart_to_rif_string = function - | It - | Nt -> "int" + | It -> "int" | Ft -> "real" | Bt -> "bool" | Et _i -> "int" - | Neighbor -> "int" + | Nt -> "int" let value_to_string = function | I i @@ -80,11 +79,10 @@ let (get_init_vars : algo_id -> (string * varT) list -> (neighbor list -> local_ (fun nl v -> match List.find_opt (fun (x,_t) -> x=v) vars with None -> failwith (v^" unknown var") - | Some(_,Neighbor) -> + | Some(_,Nt) -> assert (nl <> []); N (Random.int ((List.length nl)-1)) - | Some(_,It) - | Some(_,Nt) -> I (Random.int 100000) + | Some(_,It) -> I (Random.int 100000) | Some(_,Bt) -> B (Random.bool ()) | Some(_,Ft) -> F (Random.float max_float) | Some(_,Et i) -> I (Random.int i) diff --git a/lib/algo/algo.mli b/lib/algo/algo.mli index 4e4492c9..366b36a3 100644 --- a/lib/algo/algo.mli +++ b/lib/algo/algo.mli @@ -1,12 +1,12 @@ -(* Time-stamp: <modified the 09/03/2019 (at 15:02) by Erwan Jahier> *) +(* Time-stamp: <modified the 10/03/2019 (at 20:38) by Erwan Jahier> *) (** Process programmer API *) type value = I of int | F of float | B of bool | S of string | N of int (* neighbor canal number *) -type local_env = string -> value (* XXX assez efficace ? *) -type action = string (* label? *) +type local_env = string -> value +type action = string (* label *) -type varT = It | Nt | Ft | Bt | Et of int | Neighbor +type varT = It | Nt | Ft | Bt | Et of int type vars = (string * varT) list type neighbor = { diff --git a/test/bfs-spanning-tree/p.ml b/test/bfs-spanning-tree/p.ml index ba4e5b98..44e5efa6 100644 --- a/test/bfs-spanning-tree/p.ml +++ b/test/bfs-spanning-tree/p.ml @@ -1,10 +1,10 @@ -(* Time-stamp: <modified the 09/03/2019 (at 12:45) by Erwan Jahier> *) +(* Time-stamp: <modified the 10/03/2019 (at 20:39) by Erwan Jahier> *) (* This is algo 5.4 in the book *) open Algo -let vars = ["d",It; "par",Neighbor ] +let vars = ["d",It; "par",Nt ] let d=10 let (init_vars: neighbor list -> local_env) = -- GitLab