package core_kernel

  1. Overview
  2. Docs
Industrial strength alternative to OCaml's standard library

Install

Dune Dependency

Authors

Maintainers

Sources

v0.13.1.tar.gz
sha256=2e9dec37cf1b1a05fa3ad24ae8efd1e389b82928d598db097771405da1d6b214
md5=ee4f3b03ce7fa4cb0c27e9b02cc7712d

doc/core_kernel.balanced_reducer/Balanced_reducer/index.html

Module Balanced_reducer

A Balanced_reducer.t stores a mutable fixed-length sequence of optional values, and incrementally maintains the result of folding an associative operation (reduce) over the sequence as its elements change.

type 'a t
val sexp_of_t : ('a -> Ppx_sexp_conv_lib.Sexp.t) -> 'a t -> Ppx_sexp_conv_lib.Sexp.t
include Base.Invariant.S1 with type 'a t := 'a t
val invariant : ('a -> unit) -> 'a t -> unit
val create_exn : ?sexp_of_a:('a -> Base.Sexp.t) -> Base.unit -> len:Base.int -> reduce:('a -> 'a -> 'a) -> 'a t

create_exn ~len ~reduce creates a balanced reducer of length len, all of whose elements are None. It raises if len < 1.

val set_exn : 'a t -> Base.int -> 'a -> Base.unit

set_exn t i a updates the value at index i to Some a. It raises if i is out of bounds.

val get_exn : 'a t -> Base.int -> 'a

get_exn t i gets the value at index i. It raises if i is out of bounds, or set_exn t i has never been called.

val compute_exn : 'a t -> 'a

compute_exn t computes the value of the fold. It raises if any values of the array are None.

OCaml

Innovation. Community. Security.