Commit d7ea3174 authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Move generate_ids to Tool_credgen

parent ffcab5dd
......@@ -44,22 +44,6 @@ let load_from_file of_string filename =
Some (lines_of_file filename |> stream_to_list |> List.rev_map of_string)
) else None
let int_length n =
string_of_int n |> String.length
let rec find_first n first =
if int_length first = int_length (first + n) then first
else find_first n (10 * first)
let generate_ids n =
(* choose the first id so that they all have the same length *)
let first = find_first n 1 in
let last = first + n - 1 in
let rec loop last accu =
if last < first then accu
else loop (last-1) (string_of_int last :: accu)
in loop last []
let ( / ) = Filename.concat
exception Cmdline_error of string
......
......@@ -99,3 +99,19 @@ let make params =
let module P = (val parse_params params : PARSED_PARAMS) in
let module R = Make (P) in
(module R : S)
let int_length n =
string_of_int n |> String.length
let rec find_first n first =
if int_length first = int_length (first + n) then first
else find_first n (10 * first)
let generate_ids n =
(* choose the first id so that they all have the same length *)
let first = find_first n 1 in
let last = first + n - 1 in
let rec loop last accu =
if last < first then accu
else loop (last-1) (string_of_int last :: accu)
in loop last []
......@@ -9,3 +9,5 @@ module type S = sig
end
val make : (module PARAMS) -> (module S)
val generate_ids : int -> string 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