Module type Foldable.S
include Alg.Foldable.S
include Alg.Foldable.Seed
type 'a t
The principle type, which can be folded over using
fold_right
.
val fold_right : f:('a -> 'b -> 'b) -> 'a t -> init:'b -> 'b
fold_right ~f t ~init
combines the elements oft
usingf
from the right.
val fold : (module Alg_structs.Monoid.S with type t = 'a) -> 'a t -> 'a
fold m t
folds the elements oft
withm.op
. E.g.,# Foldable.List.fold (module Monoid.Int.Sum) [1;2;3;4];; - : int = 10
val fold_map : m:(module Alg_structs.Monoid.S with type t = 'm) -> f:('a -> 'm) -> 'a t -> 'm
fold_map ~m ~f t
is a map of the elements oft
in the monoidm
combines withm.op
.E.g.,
# Foldable.List.fold_map ~m:(module Monoid.Int.Sum) ~f:int_of_string ["1";"2";"3";"4"];; - : int = 10
val fold_left : f:('b -> 'a -> 'b) -> init:'b -> 'a t -> 'b
fold_left ~f ~init t
combines the elements oft
usingf
from the left.
val to_list : 'a t -> 'a list
to_list t
is a list with the elements oft
from left to right
val is_empty : 'a t -> bool
is_empty t
istrue
whent
is empty
val length : 'a t -> int
length t
is the number of elements int
val any : f:('a -> bool) -> 'a t -> bool
any ~f t
istrue
if the predicatef
holds for any element oft
val all : f:('a -> bool) -> 'a t -> bool
all ~f t
istrue
if the predicatef
holds for every element oft
val mem : 'a t -> 'a -> equal:('a -> 'a -> bool) -> bool
mem t x ~equal
is true if there's an elementy
int
such thatequal x t
istrue
val max : compare:('a -> 'a -> int) -> 'a t -> 'a option
max ~compare t
isSome x
whenx
is the maximum value int
, as determined bycompare
, orNone
ifis_empty t
.
val min : compare:('a -> 'a -> int) -> 'a t -> 'a option
min ~compare t
isSome x
whenm
is the minimum value int
, as determined bycompare
, orNone
ifis_empty t
.
val name : string
val arbitrary : 'a QCheck.arbitrary -> 'a t QCheck.arbitrary