module Sequential:`sig`

..`end`

The sequential implementation (to be used as a reference)

`val compute : ``worker:('a -> 'b) ->`

master:('a * 'c -> 'b -> ('a * 'c) list) -> ('a * 'c) list -> unit

`master f handle l`

applies function `f`

to each first-component
of elements in `l`

; for each such computation, both the list element
and the result are passed to `handle`

, which returns a list of
new elements to be processed (in an identical manner).
The computation stops when there is no more element to be processed.

The following functions are provided for convenience; they can be derived from the generic function above.

`val map : ``f:('a -> 'b) -> 'a list -> 'b list`

same result as `List.map`

`val map_local_fold : ``f:('a -> 'b) -> fold:('c -> 'b -> 'c) -> 'c -> 'a list -> 'c`

`map_local_fold f fold acc l`

computes
`fold ... (fold (fold acc (f x1)) (f x2)) ... (f xn)`

for some permutation `x1,x2,...,xn`

of `l`

`val map_remote_fold : ``f:('a -> 'b) -> fold:('c -> 'b -> 'c) -> 'c -> 'a list -> 'c`

same specification as above

`val map_fold_ac : ``f:('a -> 'b) -> fold:('b -> 'b -> 'b) -> 'b -> 'a list -> 'b`

same specification, assuming `fold`

is an associative and
commutative operation; the third argument should be a
neutral element for `fold`

`val map_fold_a : ``f:('a -> 'b) -> fold:('b -> 'b -> 'b) -> 'b -> 'a list -> 'b`

`map_fold_a f fold acc [x1;...xn]`

computes
`fold ... (fold (fold acc (f x1)) (f x2)) ... (f xn)`

assuming `fold`

is an associative
operation with neutral element `acc`