module Aux:sig
..end
val pi : float
exception Timeout of string
type ('a, 'b)
choice =
| |
Left of |
| |
Right of |
module Strings:Set.S
with type elt = string
val add_strings : string list -> Strings.t -> Strings.t
val strings_of_list : string list -> Strings.t
module Ints:Set.S
with type elt = int
val add_ints : int list -> Ints.t -> Ints.t
val ints_of_list : int list -> Ints.t
module StrMap:Map.S
with type key = string
val strmap_of_assoc : (string * 'a) list -> 'a StrMap.t
val strmap_filter : (string -> 'a -> bool) -> 'a StrMap.t -> (string * 'a) list
module IntMap:Map.S
with type key = int
val intmap_of_assoc : (int * 'a) list -> 'a IntMap.t
val intmap_filter : (int -> 'a -> bool) -> 'a IntMap.t -> (int * 'a) list
module BasicOperators:sig
..end
val int_pow : int -> int -> int
val is_digit : char -> bool
val fst3 : 'a * 'b * 'c -> 'a
val snd3 : 'a * 'b * 'c -> 'b
val trd3 : 'a * 'b * 'c -> 'c
val map_fst : ('a -> 'b) -> 'a * 'c -> 'b * 'c
val map_snd : ('a -> 'b) -> 'c * 'a -> 'c * 'b
val random_elem : 'a list -> 'a
val concat_map : ('a -> 'b list) -> 'a list -> 'b list
val map_prepend : 'a list -> ('b -> 'a) -> 'b list -> 'a list
Map a second list and prepend the result to the first list, in
reverse order. Tail-recursive.
val map_rev_prepend : 'a list -> ('b -> 'a) -> 'b list -> 'a list
val map_some : ('a -> 'b option) -> 'a list -> 'b list
Find the first non-None element. Raise Not_found
if none exists.
val find_some : ('a -> 'b option) -> 'a list -> 'b
val map_reduce : ('a -> 'b * 'c) -> ('d -> 'c -> 'd) -> 'd -> 'a list -> ('b * 'd) list
List.fold_left
, therefore reverses the order. The
resulting keys are sorted in the Pervasives.compare
order.val collect : ('a * 'b) list -> ('a * 'b list) list
map_reduce (fun x -> x) (fun y x->x::y) []
.val repeating_key_sorted : ('a * 'b) list -> bool
val concat_foldr : ('a -> 'b -> 'b list) -> 'a list -> 'b list -> 'b list
concat_foldr f (a::l) init = concat_map (f a) (concat_foldr f l init)
val concat_foldl : ('a -> 'b -> 'b list) -> 'a list -> 'b list -> 'b list
concat_foldl f (a::l) init = concat_foldl f l (concat_map (f a) init)
val list_rev_split : ?acc1:'a list -> ?acc2:'b list -> ('a * 'b) list -> 'a list * 'b list
val list_remove : 'a -> 'a list -> 'a list
val list_diff : 'a list -> 'a list -> 'a list
List.filter (fun e -> not (List.mem e b)) a
.val sorted_diff : 'a list -> 'a list -> 'a list
Aux.unique_sorted
).val list_inter : 'a list -> 'a list -> 'a list
list_inter a b = List.filter (fun e -> List.mem e b) a
.val list_init : (int -> 'a) -> int -> 'a list
val sorted_inter : 'a list -> 'a list -> 'a list
Aux.unique_sorted
).val sorted_merge : 'a list -> 'a list -> 'a list
Aux.unique_sorted
).val merge : ?sorted:bool ->
cmp:('a -> 'a -> int) ->
merge:('a -> 'a -> 'a) -> 'a list -> 'a list -> 'a list
cmp
-sorted list.val sorted_multiset_union : ('a * int) list -> ('a * int) list -> ('a * int) list
val rev_assoc : ('a * 'b) list -> 'b -> 'a
val mem_rev_assoc : ('a * 'b) list -> 'b -> bool
val rev_assoc_all : ('a * 'b) list -> 'b -> 'a list
val assoc_all : 'a -> ('a * 'b) list -> 'b list
val replace_assoc : 'a -> 'b -> ('a * 'b) list -> ('a * 'b) list
val pop_assoc : 'a -> ('a * 'b) list -> 'b * ('a * 'b) list
val pop_assq : 'a -> ('a * 'b) list -> 'b * ('a * 'b) list
Aux.pop_assoc
, but uses physical equality. Tail-recursive.val update_assoc : 'a -> 'b -> ('b -> 'b) -> ('a * 'b) list -> ('a * 'b) list
val cons : 'a -> 'a list -> 'a list
cons e l = e::l
.val some : 'a -> 'a option
val unsome : 'a option -> 'a
val list_of_opt : 'a option -> 'a list
val map_try : ('a -> 'b) -> 'a list -> 'b list
f
on the list collecting results whose computation does not
raise Not_found
. Therefore map_try
call cannot raise Not_found
.val find_try : ('a -> 'b) -> 'a list -> 'b
Not_found
and return its result. Raises Not_found
if
the function results in Not_found
on all elements.val fold_left_try : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a
f
over the list collecting results whose computation does
not raise Not_found
. Therefore fold_left_try
call cannot raise
Not_found
.val array_foldi_left : (int -> 'a -> 'b -> 'a) -> 'a -> 'b array -> 'a
Array.fold_left
, but with the element position passed.val power : ?timeout:(unit -> bool) -> 'a list -> 'b list -> ('a * 'b) list list
power dom img
generates all functions with domain dom
and
image img
, as graphs. Tail recursive.val product : ?upto:int -> ?timeout:(unit -> bool) -> 'a list list -> 'a list list
val product_size : 'a list list -> int
val pairs : 'a list -> ('a * 'a) list
val all_ntuples : ?timeout:(unit -> bool) -> 'a list -> int -> 'a list list
n
th cartesian power of the list. Tail recursive.val all_subsets : ?max_size:int -> 'a list -> 'a list list
set
of size up to max_size
.val remove_one : 'a -> 'a list -> 'a list
val remove_last : 'a list -> 'a list
val insert_nth : int -> 'a -> 'a list -> 'a list
n
th element of a list (counting from zero). Raise
Not_found
if the list has less than n
elements (e.g. inserting
0th element to empty list is OK).val find_index : 'a -> 'a list -> int
val pop_find : ('a -> bool) -> 'a list -> 'a * 'a list
val maximal : ('a -> 'a -> bool) -> 'a list -> 'a list
val maximal_o : ('a -> 'a -> bool) -> 'a list -> 'a
val maximal_unique : ('a -> 'a -> bool) -> 'a list -> 'a list
val add_to_maximal : ('a -> 'a -> bool) -> 'a list -> 'a list -> 'a list
l2
already has only maximal elements,
add_to_maximal cmp l1 l2
computes maximal cmp (l1 @ l2)
.type 'a
topol_sort_ops = {
|
rem_edge : |
(* | rem_edge a b removes a->b . | *) |
|
iter_outgoing : |
|||
|
no_incoming : |
|||
|
node_to_string : |
Aux.topol_sort
.val topol_sort : 'a topol_sort_ops -> 'a list -> 'a list
l
where cmp a b = true
means that there is
an arrow from a
to b
. Elements without incoming edges are first
and elements without outgoing edges are last. Returns None
/
raises Not_found
if a cycle is detected.
Implementation:
http://en.wikipedia.org/wiki/Topological_sort#Algorithms
val unique_sorted : ?cmp:('a -> 'a -> int) -> 'a list -> 'a list
Pervasives.compare
. Not tail-recursive.val unique_append : 'a list -> 'a list -> 'a list
unique_append l1 l2
appends elements not occurring in l2
to
it, without repeating elements.val unique : ('a -> 'a -> bool) -> 'a list -> 'a list
n^2
algorithm. Currently not tail-recursive.)val not_unique : 'a list -> bool
val take_n : int -> 'a list -> 'a list
n
elements of the given list, or less it the list does not
contain enough values.val take_n_with_rest : int -> 'a list -> 'a list * 'a list
n
elements of the given list, or less it the list does not
contain enough values. Return the rest-list as the second argument.val range : ?from:int -> int -> int list
from
(default 0) to k-1.val array_from_assoc : (int * 'a) list -> 'a array
0..length-1
range; raises
Invalid_argument "Aux.array_from_assoc"
otherwise.val array_map_some : ('a -> 'b option) -> 'a array -> 'b array
val array_mapi_some : (int -> 'a -> 'b option) -> 'a array -> 'b array
val array_map2 : ('a -> 'b -> 'c) -> 'a array -> 'b array -> 'c array
Invalid_argument
if the arrays are of different lengths.val array_for_all2 : ('a -> 'b -> bool) -> 'a array -> 'b array -> bool
val array_fold_left2 : ('a -> 'b -> 'c -> 'a) -> 'a -> 'b array -> 'c array -> 'a
val array_fold_map2 : ('a -> 'b -> 'c -> 'a * 'd) -> 'a -> 'b array -> 'c array -> 'a * 'd array
val array_combine : 'a array -> 'b array -> ('a * 'b) array
Invalid_argument
"Aux.array_map2"
if the arrays are of different lengths.val array_exists : ('a -> bool) -> 'a array -> bool
val array_existsi : (int -> 'a -> bool) -> 'a array -> bool
val array_mem : 'a -> 'a array -> bool
val array_map_of_list : ('a -> 'b) -> 'a list -> 'b array
Array.of_list (List.map f l)
val array_argfind : ('a -> bool) -> 'a array -> int
val array_argfindi : (int -> 'a -> bool) -> 'a array -> int
val array_find_all : ('a -> bool) -> 'a array -> 'a list
f
holds.
Find all indices for which f
holds.
val array_argfind_all : ('a -> bool) -> 'a array -> int list
val array_for_all : ('a -> bool) -> 'a array -> bool
val array_for_alli : (int -> 'a -> bool) -> 'a array -> bool
val array_for_all2 : ('a -> 'b -> bool) -> 'a array -> 'b array -> bool
Invalid_argument "Aux.array_for_all2"
if
arrays are of different lengths.val array_iter2 : ('a -> 'b -> unit) -> 'a array -> 'b array -> unit
Invalid_argument "Aux.array_iter2"
if
arrays are of different lengths.val array_replace : 'a array -> int -> 'a -> 'a array
array
with the i
th element replaced by elem
.val list_find_all_max : ('a -> 'a -> int) -> 'a list -> 'a list
Find all maximal elements in an array.
val array_find_all_max : ('a -> 'a -> int) -> 'a array -> 'a list
val array_argfind_all_max : ('a -> 'a -> int) -> 'a array -> int list
val neg : ('a -> bool) -> 'a -> bool
neg f x = not (f x)
val is_right : ('a, 'b) choice -> bool
val partition_choice : ('a, 'b) choice list -> 'a list * 'b list
Left
and
Right
-tagged elements.val partition_map : ('a -> ('b, 'c) choice) -> 'a list -> 'b list * 'c list
val map_choice : ('a -> 'b) -> ('c -> 'd) -> ('a, 'c) choice -> ('b, 'd) choice
val map_option : ('a -> 'b) -> 'a option -> 'b option
None
case.val omap : 'b -> ('a -> 'b) -> 'a option -> 'b
val transpose_lists : 'a list list -> 'a list list
Invalid_argument "List.map2"
when matrix is not rectangular.val fold_n : ('a -> 'a) -> 'a -> int -> 'a
n
times: f^n(x)
.val not_conflicting_name : ?truncate:bool -> Strings.t -> string -> string
s
and not appearing in names
. If
truncate
is true, remove numbers from the end of s
.val not_conflicting_names : ?truncate:bool -> string -> Strings.t -> 'a list -> string list
n
strings proloning s
and not appearing in names
.val list_fprint : (Pervasives.out_channel -> 'a -> unit) ->
Pervasives.out_channel -> 'a list -> unit
val array_fprint : (Pervasives.out_channel -> 'a -> unit) ->
Pervasives.out_channel -> 'a array -> unit
val fprint_sep_list : ?newline:int ->
string ->
(Format.formatter -> 'a -> unit) -> Format.formatter -> 'a list -> unit
val is_uppercase : char -> bool
val is_lowercase : char -> bool
val is_digit : char -> bool
val is_letter : char -> bool
val is_alphanum : char -> bool
val is_space : char -> bool
val clean_name : string -> string
s
to use only alphanumeric characters and underscore
and to start with a lowercase letter. *val strip_charprop : (char -> bool) -> string -> string
f
from left and right of a string.val strip_spaces : string -> string
val split_charprop : ?keep_split_chars:bool -> (char -> bool) -> string -> string list
f
.type
split_result =
| |
Text of |
| |
Delim of |
val split_chars_after : char -> char list -> string -> split_result list
l
after c
, split on such pairs. *val split_spaces : string -> string list
val split_newlines : string -> string list
val split_empty_lines : string -> string list
val normalize_spaces : string -> string
val replace_charprop : (char -> bool) -> string -> string -> string
f
by repl
.val str_index : ?from:int -> string -> string -> int
from
count. If it does not occur, raise Not_found.val str_contains : string -> string -> bool
val str_subst_once : string -> string -> string -> string
val str_subst_all : string -> string -> string -> string
val str_subst_once_from_to : string -> string -> string -> string -> string
val str_subst_all_from_to : string -> string -> string -> string -> string
module type PRIOQUEUE =sig
..end
module SimplePrioQueue:PRIOQUEUE
module LeftistPrioQueue:PRIOQUEUE