Commit 3a74b382 authored by POTTIER Francois's avatar POTTIER Francois

Implement [visit_array] in [mapreduce2].

parent 22717ba5
...@@ -1001,10 +1001,28 @@ end ...@@ -1001,10 +1001,28 @@ end
(* [mapreduce2] *) (* [mapreduce2] *)
class virtual ['self] mapreduce2 = object (_self) class virtual ['self] mapreduce2 = object (self)
inherit ['s] monoid inherit ['s] monoid
method private visit_array: 'env 'a 'b 'c .
('env -> 'a -> 'b -> 'c * 's) -> 'env -> 'a array -> 'b array -> 'c array * 's
= fun f env xs1 xs2 ->
let n1 = Array.length xs1
and n2 = Array.length xs2 in
if n1 = n2 then
let s = ref self#zero in
let xs = Array.init n1 (fun i ->
let x1 = Array.unsafe_get xs1 i
and x2 = Array.unsafe_get xs2 i in
let x, sx = f env x1 x2 in
s := self#plus !s sx;
x
) in
xs, !s
else
fail()
(* TEMPORARY *) (* TEMPORARY *)
end end
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