Commit 98d78298 authored by Stephane Glondu's avatar Stephane Glondu

Add Shape.flatten

parent 06d4ba57
......@@ -226,6 +226,10 @@ module Shape = struct
| SArray x, SArray y -> SArray (Array.map2 (map2 f) x y)
| _, _ -> invalid_arg "Shape.map2"
let rec flatten = function
| SAtomic x -> [x]
| SArray xs -> Array.map flatten xs |> Array.to_list |> List.flatten
let split x =
map fst x, map snd x
......
......@@ -70,6 +70,7 @@ module Shape : sig
val to_array_array : 'a t -> 'a array array
val map : ('a -> 'b) -> 'a t -> 'b t
val map2 : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t
val flatten : 'a t -> 'a list
val split : ('a * 'b) t -> 'a t * 'b t
val forall : ('a -> bool) -> 'a t -> bool
val forall2 : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool
......
......@@ -116,7 +116,7 @@ module Make (W : ELECTION_DATA) (M : RANDOM) = struct
List.flatten (
List.map (fun {alpha; beta} ->
[alpha; beta]
) (Array.to_list (Shape.to_array (Q.extract_ciphertexts a)))
) (Shape.flatten (Q.extract_ciphertexts a))
)
) (Array.to_list answers)
) |> Array.of_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