Page
Library
Module
Module type
Parameter
Class
Class type
Source
LazyListAn alternative to the batteries lazy list library, with generally improved laziness.
val nil : 'a tval singleton : 'a -> 'a tval repeat : 'a -> 'a tA constant stream of the input.
val from : (unit -> 'a) -> 'a tA list whose elements come from unit-delayed expressions.
val of_list : 'a list -> 'a tConvert an eager list to a lazy one.
val range : int -> int -> int tThe lazy list of values 0..n
val unfold : 'a -> ('a -> ('b * 'a) option) -> 'b tCreate a list using a function representing the body of a loop. The loop terminates when the body returns None.
val hd : 'a t -> 'aval is_empty : 'a t -> boolval is_non_empty : 'a t -> boolval any : ('a -> bool) -> 'a t -> boolTests whether any element of the list is satisfied by a predicate.
val all : ('a -> bool) -> 'a t -> boolTests whether every element of the list is satisfied by a predicate.
Take elements to the first element for which the predicate fails.
Drop elements until the first element for which the predicate fails.
span p xs is equivalent to (take_while p xs, drop_while p xs).
Splits a list into those elements which satisfy a predicate and those which don't.
Maps a binary function across corresponding elements of two lists.
Maps a binary function across corresponding elements of two lists, up to the length of the shortest list.
val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'aval fold_left1 : ('a -> 'a -> 'a) -> 'a t -> 'aMaps a function across a list whilst accumulating a state value.
As map_accum_l, but also returns the final accumulated value. The input list will be forced only once, even if both components of the pair are forced. However, two passes of the list are still required.
Tests whether every element in the first list is equivalent to the elements in the second list.
val mem : ?cmp:('a -> 'a -> bool) -> 'a -> 'a t -> boolBased on a partial order. Any element in the first argument which is smaller than an element in the second is removed.
Retains elements in the first argument which are equivalent to some element in the second.
Retains elements in the first argument which are equivalent to some element in the second, and vice versa.
Reduce a list to its maxima according to the partial-order.
val length : 'a t -> intThe following function is sometimes useful for defining recursive lists.
val iter : ('a -> unit) -> 'a t -> unitLoops a side-effecting procedure over the elements of a list.
val to_list : 'a t -> 'a listval enum : 'a t -> 'a BatEnum.tval is_forced : 'a t -> boolTrue if the whole list has been forced.
val find_all : ('a -> 'b -> bool) -> 'a list -> 'b t -> 'b listFind all elements of a set.