package bap-std
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=63ada71fa4f602bd679174dc6bf780d54aeded40ad4ec20d256df15886e3d2d5
md5=b8b1aff8c6846f2213eafc54de07b304
doc/bap/Bap/Std/Bili/Make/argument-1-M/Seq/index.html
Module M.Seq
The Monad.Collection.S2 interface for sequences
val all :
('a, 'e) t Core_kernel.Sequence.t ->
('a Core_kernel.Sequence.t, 'e) tall cs performs all computations in cs and returns a list of results in the same order. The order of evaluation is unspecified.
val all_ignore : ('a, 'e) t Core_kernel.Sequence.t -> (unit, 'e) tall_ignore cs performs all computations in cs in an unspecified order, and discards the results.
val sequence : (unit, 'e) t Core_kernel.Sequence.t -> (unit, 'e) tsequence cs performs all computations in cs from left to right.
val map :
'a Core_kernel.Sequence.t ->
f:('a -> ('b, 'e) t) ->
('b Core_kernel.Sequence.t, 'e) tmap xs ~f returns a container where n'th element is a result of computation f x_n, where x_n is the n'th element of the input container. It is unspecified, in which order the computations are evaluated, and whether all computations are performed.
val iter : 'a Core_kernel.Sequence.t -> f:('a -> (unit, 'e) t) -> (unit, 'e) titer xs ~f performs f x for each x in xs in the left to right order.
val fold :
'a Core_kernel.Sequence.t ->
init:'b ->
f:('b -> 'a -> ('b, 'e) t) ->
('b, 'e) tfold xs ~init:s0 ~f folds f over xs in the given monad.
Effectively computes a chain:
f s0 x0 >>= fun s1 -> f s1 x1 >>= fun s2 -> ... f sN xN
Except that the computation uses a constant stack size.
val fold_left :
'a Core_kernel.Sequence.t ->
init:'b ->
f:('b -> 'a -> ('b, 'e) t) ->
('b, 'e) tfold_left is a synonym for fold.
val fold_right :
'a Core_kernel.Sequence.t ->
f:('a -> 'b -> ('b, 'e) t) ->
init:'b ->
('b, 'e) tfold_right xs ~f ~init:s0 folds f over xs from right to left in the given monad.
Effectively computes a chain:
f x_N s0 >>= fun s1 -> f x_(N-1) s1 >>= fun s2 -> ... f x0 s_N
Except that the computation uses a constant stack size.
val reduce :
'a Core_kernel.Sequence.t ->
f:('a -> 'a -> ('a, 'e) t) ->
('a option, 'e) treduce xs ~f same as fold except that the initial state is obtained from the first element of the container, i.e., computes a sequence
f x0 x1 >>= fun s1 -> f s1 x2 >>= fun s2 -> ... f sN xN
val exists :
'a Core_kernel.Sequence.t ->
f:('a -> (bool, 'e) t) ->
(bool, 'e) texists xs ~f returns a computation that results in true iff there exists an element x in xs such that f x evaluates to true
val for_all :
'a Core_kernel.Sequence.t ->
f:('a -> (bool, 'e) t) ->
(bool, 'e) tfor_all xs ~f returns a computation that results in true iff for all x in xs f x evaluates to true.
val count : 'a Core_kernel.Sequence.t -> f:('a -> (bool, 'e) t) -> (int, 'e) tcount xs ~f returns a computation that results to a number of elements of xs for which f evaluates to true. The order of application of f is unspecified.
val map_reduce :
(module Monads.Std.Monoid.S with type t = 'a) ->
'b Core_kernel.Sequence.t ->
f:('b -> ('a, 'e) t) ->
('a, 'e) tmap_reduce (module Monoid) xs ~f a composition of map and reduce. Effectively the same as map xs ~f and then reduce in Monoid except that no intermediate collections are created.
val find :
'a Core_kernel.Sequence.t ->
f:('a -> (bool, 'e) t) ->
('a option, 'e) tfind xs ~f returns the first element x of xs for which f x evaluates to true.
val find_map :
'a Core_kernel.Sequence.t ->
f:('a -> ('b option, 'e) t) ->
('b option, 'e) tfind_map xs ~f returns the first computation f x for x in xs which will result in non None.
val filter :
'a Core_kernel.Sequence.t ->
f:('a -> (bool, 'e) t) ->
('a Core_kernel.Sequence.t, 'e) tfilter xs ~f returns a computation that contains all the elements of xs for which f evaluated to true. The order of the elements is the same.
val filter_map :
'a Core_kernel.Sequence.t ->
f:('a -> ('b option, 'e) t) ->
('b Core_kernel.Sequence.t, 'e) tfilter_map xs ~f is a partial mapping from xs to a collection ys, such that all the elements of xs for which f returned Some value are mapped, while the rest are omitted.