Commit 5d0e34e4 authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Cleanup

parent 56edcd81
...@@ -4,13 +4,6 @@ let ( =% ) = Z.equal ...@@ -4,13 +4,6 @@ let ( =% ) = Z.equal
module Array = struct module Array = struct
include Array include Array
let forall f a =
let n = Array.length a in
(let rec check i =
if i >= 0 then f a.(i) && check (pred i)
else true
in check (pred n))
let forall2 f a b = let forall2 f a b =
let n = Array.length a in let n = Array.length a in
n = Array.length b && n = Array.length b &&
...@@ -76,9 +69,6 @@ module Array = struct ...@@ -76,9 +69,6 @@ module Array = struct
let map2 f a b = let map2 f a b =
Array.mapi (fun i ai -> f ai b.(i)) a Array.mapi (fun i ai -> f ai b.(i)) a
let map2i f a b =
Array.mapi (fun i ai -> f i ai b.(i)) a
let map3 f a b c = let map3 f a b c =
Array.mapi (fun i ai -> f ai b.(i) c.(i)) a Array.mapi (fun i ai -> f ai b.(i) c.(i)) a
...@@ -130,21 +120,3 @@ module String = struct ...@@ -130,21 +120,3 @@ module String = struct
let xn = String.length x and sn = String.length s in let xn = String.length x and sn = String.length s in
xn >= sn && String.sub x 0 sn = s xn >= sn && String.sub x 0 sn = s
end end
let hashB x = Cryptokit.(x |>
hash_string (Hash.sha256 ()) |>
transform_string (Base64.encode_compact ())
)
let load_from_file read fname =
let i = open_in fname in
let buf = Lexing.from_channel i in
let lex = Yojson.init_lexer ~fname () in
let result = read lex buf in
close_in i;
result
let non_empty_lines_of_file fname =
Lwt_io.lines_of_file fname |>
Lwt_stream.filter (fun s -> s <> "") |>
Lwt_stream.to_list
...@@ -8,7 +8,6 @@ end ...@@ -8,7 +8,6 @@ end
module Array : sig module Array : sig
include module type of Array include module type of Array
val forall : ('a -> bool) -> 'a array -> bool
val forall2 : ('a -> 'b -> bool) -> 'a array -> 'b array -> bool val forall2 : ('a -> 'b -> bool) -> 'a array -> 'b array -> bool
val foralli : (int -> 'a -> bool) -> 'a array -> bool val foralli : (int -> 'a -> bool) -> 'a array -> bool
val fforall : ('a -> bool) -> 'a array array -> bool val fforall : ('a -> bool) -> 'a array array -> bool
...@@ -17,7 +16,6 @@ module Array : sig ...@@ -17,7 +16,6 @@ module Array : sig
val fforall3 : ('a -> 'b -> 'c -> bool) -> val fforall3 : ('a -> 'b -> 'c -> bool) ->
'a array array -> 'b array array -> 'c array array -> bool 'a array array -> 'b array array -> 'c array array -> bool
val map2 : ('a -> 'b -> 'c) -> 'a array -> 'b array -> 'c array val map2 : ('a -> 'b -> 'c) -> 'a array -> 'b array -> 'c array
val map2i : (int -> 'a -> 'b -> 'c) -> 'a array -> 'b array -> 'c array
val map3 : ('a -> 'b -> 'c -> 'd) -> val map3 : ('a -> 'b -> 'c -> 'd) ->
'a array -> 'b array -> 'c array -> 'd array 'a array -> 'b array -> 'c array -> 'd array
val mmap : ('a -> 'b) -> 'a array array -> 'b array array val mmap : ('a -> 'b) -> 'a array array -> 'b array array
...@@ -33,9 +31,3 @@ module String : sig ...@@ -33,9 +31,3 @@ module String : sig
val map : (char -> char) -> string -> string val map : (char -> char) -> string -> string
val startswith : string -> string -> bool val startswith : string -> string -> bool
end end
val hashB : string -> string
val load_from_file : (Yojson.lexer_state -> Lexing.lexbuf -> 'a) ->
string -> 'a
val non_empty_lines_of_file : string -> string list Lwt.t
...@@ -2,6 +2,11 @@ open Lwt ...@@ -2,6 +2,11 @@ open Lwt
open Util open Util
open Serializable_compat_t open Serializable_compat_t
let hashB x = Cryptokit.(x |>
hash_string (Hash.sha256 ()) |>
transform_string (Base64.encode_compact ())
)
let if_legacy s = let if_legacy s =
if String.length s = 38 && s.[0] = '{' && s.[37] = '}' if String.length s = 38 && s.[0] = '{' && s.[37] = '}'
then Uuidm.of_string ~pos:1 s then Uuidm.of_string ~pos:1 s
......
...@@ -15,6 +15,19 @@ let enforce_single_element s = ...@@ -15,6 +15,19 @@ let enforce_single_element s =
(assert_lwt b) >> (assert_lwt b) >>
Lwt.return t Lwt.return t
let load_from_file read fname =
let i = open_in fname in
let buf = Lexing.from_channel i in
let lex = Yojson.init_lexer ~fname () in
let result = read lex buf in
close_in i;
result
let hashB x = Cryptokit.(x |>
hash_string (Hash.sha256 ()) |>
transform_string (Base64.encode_compact ())
)
let load_elections_and_votes dirname = let load_elections_and_votes dirname =
Lwt_unix.files_of_directory dirname |> Lwt_unix.files_of_directory dirname |>
Lwt_stream.filter_map_s (fun x -> Lwt_stream.filter_map_s (fun x ->
......
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