Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
belenios
belenios
Commits
5d0e34e4
Commit
5d0e34e4
authored
Apr 29, 2013
by
Stephane Glondu
Browse files
Cleanup
parent
56edcd81
Changes
4
Hide whitespace changes
Inline
Side-by-side
lib/util.ml
View file @
5d0e34e4
...
...
@@ -4,13 +4,6 @@ let ( =% ) = Z.equal
module
Array
=
struct
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
n
=
Array
.
length
a
in
n
=
Array
.
length
b
&&
...
...
@@ -76,9 +69,6 @@ module Array = struct
let
map2
f
a
b
=
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
=
Array
.
mapi
(
fun
i
ai
->
f
ai
b
.
(
i
)
c
.
(
i
))
a
...
...
@@ -130,21 +120,3 @@ module String = struct
let
xn
=
String
.
length
x
and
sn
=
String
.
length
s
in
xn
>=
sn
&&
String
.
sub
x
0
sn
=
s
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
lib/util.mli
View file @
5d0e34e4
...
...
@@ -8,7 +8,6 @@ end
module
Array
:
sig
include
module
type
of
Array
val
forall
:
(
'
a
->
bool
)
->
'
a
array
->
bool
val
forall2
:
(
'
a
->
'
b
->
bool
)
->
'
a
array
->
'
b
array
->
bool
val
foralli
:
(
int
->
'
a
->
bool
)
->
'
a
array
->
bool
val
fforall
:
(
'
a
->
bool
)
->
'
a
array
array
->
bool
...
...
@@ -17,7 +16,6 @@ module Array : sig
val
fforall3
:
(
'
a
->
'
b
->
'
c
->
bool
)
->
'
a
array
array
->
'
b
array
array
->
'
c
array
array
->
bool
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
)
->
'
a
array
->
'
b
array
->
'
c
array
->
'
d
array
val
mmap
:
(
'
a
->
'
b
)
->
'
a
array
array
->
'
b
array
array
...
...
@@ -33,9 +31,3 @@ module String : sig
val
map
:
(
char
->
char
)
->
string
->
string
val
startswith
:
string
->
string
->
bool
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
tests/sandbox.ml
View file @
5d0e34e4
...
...
@@ -2,6 +2,11 @@ open Lwt
open
Util
open
Serializable_compat_t
let
hashB
x
=
Cryptokit
.(
x
|>
hash_string
(
Hash
.
sha256
()
)
|>
transform_string
(
Base64
.
encode_compact
()
)
)
let
if_legacy
s
=
if
String
.
length
s
=
38
&&
s
.
[
0
]
=
'
{
'
&&
s
.
[
37
]
=
'
}
'
then
Uuidm
.
of_string
~
pos
:
1
s
...
...
web/common.ml
View file @
5d0e34e4
...
...
@@ -15,6 +15,19 @@ let enforce_single_element s =
(
assert_lwt
b
)
>>
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
=
Lwt_unix
.
files_of_directory
dirname
|>
Lwt_stream
.
filter_map_s
(
fun
x
->
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment