module List_util: sig .. end
Utility functions for lists.
module Hashed_list:
val count : ('a -> bool) -> 'a list -> int
count p l is the number of elements in
l for which
p holds.
val exists_unique : ('a -> bool) -> 'a list -> bool
exists_unique p l holds when
p for exactly one element of
l.
- Ensure:
exists_unique p l = (count p l = 1)
val remove_sorted_duplicates : ('a -> 'a -> int) -> 'a list -> 'a list
A list sorted in ascending order according to a comparison
function, with duplicate elements removed. The comparison
function returns a positive integer if the first argument is
considered greater than the second, and a negative integer if it
is considered less. If the comparison function returns zero for
two elements then they are considered equal, both for sorting
and duplicate removal.
val iter_pairwise : ('a -> 'a -> unit) -> 'a list -> unit
iter_pairwise f l applies f to all pairs (a,b) such
that a occurs in l and b occurs after a in l.
val find_index : ('a -> bool) -> 'a list -> int
find_index p l is the index of the first element in
l that
satisfies
p.
- Raises
Not_found if no element in l satisfies p
val pp_print_list : (Format.formatter -> 'a -> unit) ->
(Format.formatter -> unit -> unit) -> Format.formatter -> 'a list -> unit
Given a function for printing a list element and a function for
printing a list element seperater, print a list. pp_print_list
pe ps f [e0; e1; ... en] performs pe f e0; ps f (); pe f e1;
ps f (); ... pe f en.
Hosted by the
* web site.
*Other names and brands may be claimed as the property
of others.