A lightweight reactive document library.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

#### 39 lines 1.1 KiB Raw Normal View History

 2 years ago `type 'a monoid = 'a * ('a -> 'a -> 'a)` 1 year ago `(** A monoid, defined by a default element and an associative operation *)` ``` ``` 2 years ago `val lift_monoid : 'a monoid -> 'a Lwd.t monoid` 1 year ago `(** Use a monoid inside [Lwd] *)` ``` ``` ```(** {1 List reduction functions} ``` ``` ``` ` All reductions are balanced, relying on operator associativity.` 1 year ago ``` ``` ` [fold_left] would compute a chain like:` 1 year ago ` [fold f [a; b; c; d] = f a (f b (f c d)]` 1 year ago ``` ``` 1 year ago ` [reduce] uses tree-shaped computations like:` ` [reduce f [a; b; c; d] = f (f a b) (f c d)]` ``` ``` ` The depth of the computation grows in O(log n) where n is the length of the` ` input sequence.` `*)` 2 years ago ``` ``` `val pack : 'a monoid -> 'a Lwd.t list -> 'a Lwd.t` 1 year ago `(** Reduce a list of elements in [Lwd] monad *)` ``` ``` 2 years ago `val pack_seq : 'a monoid -> 'a Lwd.t Seq.t -> 'a Lwd.t` 1 year ago `(** Reduce an (OCaml) [Seq.t] with a monoid *)` ``` ``` `val reduce : 'a monoid -> 'a list -> 'a` `(** Reduce a list with a monoid **)` 2 years ago ``` ``` 1 year ago `val map_reduce : ('a -> 'b) -> 'b monoid -> 'a list -> 'b` 1 year ago `(** Map and reduce a list with a monoid **)` 1 year ago ``` ``` 1 year ago `(** {1 Other Lwd list functions} *)` 2 years ago ``` ``` `val map_l : ('a -> 'b Lwd.t) -> 'a list -> 'b list Lwd.t` ``` ``` `val flatten_l : 'a Lwd.t list -> 'a list Lwd.t` 1 year ago `(** Commute [Lwd] and [list] *)`