Commit f6db67de authored by POTTIER Francois's avatar POTTIER Francois

Manual implementation of [mapreduce] for arrays.

parent edeab32f
......@@ -540,6 +540,19 @@ class virtual ['self] mapreduce = object (self : 'self)
inherit ['s] monoid
method private visit_array: 'env 'a 'b .
('env -> 'a -> 'b * 's) -> 'env -> 'a array -> 'b array * 's
= fun f env xs ->
let s = ref self#zero in
let xs =
Array.map (fun x ->
let x, sx = f env x in
s := self#plus !s sx;
x
) xs
in
xs, !s
method private visit_list: 'env 'a 'b .
('env -> 'a -> 'b * 's) -> 'env -> 'a list -> 'b list * 's
= fun f env xs ->
......
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