package hack_parallel

  1. Overview
  2. Docs
Parallel and shared memory library

Install

Dune Dependency

Authors

Maintainers

Sources

1.0.1.tar.gz
md5=ba7c72bc207e326b72e294fc76f6ad2c
sha512=5020d47f97bea2f88e2a40411894d03232a7f2282606926c93c7d4c96d72e94a966be852897a9b16f7e0893ba376512045abb9d93020a7c03c3def4f3d918f8e

doc/src/hack_parallel.hack_core/hack_container.ml.html

Source file hack_container.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
let fold_count fold t ~f = fold t ~init:0 ~f:(fun n a -> if f a then n + 1 else n)

let fold_sum (type a) (module M : Hack_commutative_group.S with type t = a) fold t ~f =
  fold t ~init:M.zero ~f:(fun n a -> M.(+) n (f a))
;;

let fold_min fold t ~cmp =
  fold t ~init:None ~f:(fun acc elt ->
      match acc with
      | None -> Some elt
      | Some min -> if cmp min elt > 0 then Some elt else acc)
;;

let fold_max fold t ~cmp =
  fold t ~init:None ~f:(fun acc elt ->
      match acc with
      | None -> Some elt
      | Some max -> if cmp max elt < 0 then Some elt else acc)
;;
OCaml

Innovation. Community. Security.