Commit 4453ebfc authored by POGODALLA Sylvain's avatar POGODALLA Sylvain

Fixes bad generation of variable names (including non-ascii characters) in...

Fixes bad generation of variable names (including non-ascii characters) in datalog programs when there are more than 26 of them
parent 66d85909
......@@ -7,9 +7,15 @@ struct
let compare (Var i) (Var j)=i-j
let succ (Var i)=Var (i+1)
let start=Var 0
let to_string (Var i) =
let c = Printf.sprintf "%c" (char_of_int (97+i)) in
c
let to_string (Var i) =
let dec = decompose ~input:i ~base:26 in
List.fold_left
(fun acc i ->
Printf.sprintf "%s%c" acc (char_of_int (97+i)))
""
dec
(* let c = Printf.sprintf "%c" (char_of_int (97+i)) in
c *)
end
......
......@@ -168,3 +168,12 @@ let log_iteration log_function s =
log_function
(Bolt.Utils.split "\n" s)
*)
let decompose ~input ~base =
let rec decompose_aux i b res =
let q = i / b in
let r = i mod b in
match q with
| 0 -> r::res
| _ -> decompose_aux q base (r::res) in
decompose_aux input base []
......@@ -97,3 +97,8 @@ val (>>) : ('b -> 'c) -> ('a -> 'b) -> ('a -> 'c)
NONE *)
(*val log_iteration : (string -> unit) -> string -> unit *)
(** [decompose ~input:i ~base:b] returns the decomposition of [i] in
the base [b] as a list of integers (between [0] and [b]). *)
val decompose : input:int -> base:int -> int list
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment