package alg_structs
Module type Foldable.SSource
The Seed needed to generate an implementation of Foldable for the type t.
include Seed
The principle type, which can be folded over using fold_right.
val fold_right : f:('a -> 'b -> 'b) -> 'a t -> init:'b -> 'bfold_right ~f t ~init combines the elements of t using f from the right.
fold m t folds the elements of t with m.op. E.g.,
# Foldable.List.fold (module Monoid.Int.Sum) [1;2;3;4];;
- : int = 10fold_map ~m ~f t is a map of the elements of t in the monoid m combines with m.op.
E.g.,
# Foldable.List.fold_map ~m:(module Monoid.Int.Sum) ~f:int_of_string ["1";"2";"3";"4"];;
- : int = 10val fold_left : f:('b -> 'a -> 'b) -> init:'b -> 'a t -> 'bfold_left ~f ~init t combines the elements of t using f from the left.
val to_list : 'a t -> 'a listto_list t is a list with the elements of t from left to right
val is_empty : 'a t -> boolis_empty t is true when t is empty
val length : 'a t -> intlength t is the number of elements in t
val any : f:('a -> bool) -> 'a t -> boolany ~f t is true if the predicate f holds for any element of t
val all : f:('a -> bool) -> 'a t -> boolall ~f t is true if the predicate f holds for every element of t
val mem : 'a t -> 'a -> equal:('a -> 'a -> bool) -> boolmem t x ~equal is true if there's an element y in t such that equal x t is true
val max : compare:('a -> 'a -> int) -> 'a t -> 'a optionmax ~compare t is Some x when x is the maximum value in t, as determined by compare, or None if is_empty t.
val min : compare:('a -> 'a -> int) -> 'a t -> 'a optionmin ~compare t is Some x when m is the minimum value in t, as determined by compare, or None if is_empty t.