]> matita.cs.unibo.it Git - pkg-cerco/acc.git/blob - src/utilities/miscPottier.mli
first version of the package
[pkg-cerco/acc.git] / src / utilities / miscPottier.mli
1
2 (** This module provides some additional functions on lists or arithmetics. *)
3
4 (* raises Not_found *)
5 val pos : 'a -> 'a list -> int
6
7 val reduce : 'a list -> 'b list -> ('a list * 'a list) * ('b list * 'b list)
8
9 (* raise Failure "MiscPottier.map3" if the list arguments are not of the same
10    size. *)
11 val map3 : ('a -> 'b -> 'c -> 'd) -> 'a list -> 'b list -> 'c list -> 'd list
12
13 val max_list : 'a list -> 'a
14
15 val pow : int -> int -> int
16
17 val make: 'a -> int -> 'a list
18
19 val index_of : 'a -> 'a list -> int
20
21 val foldi_until : int -> (int -> 'a -> 'b -> 'a) -> 'a -> 'b list -> 'a
22
23 val foldi : (int -> 'a -> 'b -> 'a) -> 'a -> 'b list -> 'a
24
25 val iteri : (int -> 'a -> unit) -> 'a list -> unit
26
27 val mapi : (int -> 'a -> 'b) -> 'a list -> 'b list
28
29 (* Raises Not_found if the list is empty. *)
30 val last : 'a list -> 'a
31
32 (* [split l i] splits the list [l] in two lists: one with the elements
33    up until the [i]th (exclusive) and one with the rest. *)
34 val split: 'a list -> int -> ('a list * 'a list)
35
36 (* [split_last l] returns the list [l] without its last element and its last
37    element. Raises Invalid_argument "MiscPottier.split_last" if the list is
38    empty. *)
39 val split_last : 'a list -> ('a list * 'a)
40
41 val update_list_assoc: 'a -> 'b -> ('a * 'b) list -> ('a * 'b) list
42
43 (* Pasted from Pottier's PP compiler *)
44
45 (* [combine] turns a pair of lists into a list of pairs. It never
46    fails: the length of the output list is the minimum of the lengths
47    of the input lists. *)
48
49 val combine: 'a list -> 'b list -> ('a * 'b) list
50
51 (* [subtract xs1 xs2] returns the list [xs1] deprived of as many
52    elements as there are in the list [xs2]. *)
53
54 val subtract: 'a list -> 'b list -> 'a list
55
56 (* [mirror] reverses the order of the pair components in a list
57    of pairs. *)
58
59 val mirror: ('a * 'b) list -> ('b * 'a) list
60
61 (* [length l] is the length of the list [l]. *)
62
63 val length: 'a list -> int32
64
65 (* [prefix k xs] returns the prefix of length [k] of the list [xs].
66    If [xs] has length less than [k], [xs] is returned. *)
67
68 val prefix: int -> 'a list -> 'a list
69
70 (* [memoize f] produces a memoizing version of the function [f].
71    It requires the domain of [f] to support generic equality. *)
72
73 val memoize: ('a -> 'b) -> ('a -> 'b)
74
75 (* [filter_map filter map l] returns the list [l] where elements satisfying the
76    [filter] function have been replaced by their application to the [map]
77    function. Elements that do not satisfy [filter] are not in the result
78    list. *)
79
80 val filter_map: ('a -> bool) -> ('a -> 'b) -> 'a list -> 'b list
81
82 (* [string_of_list sep f l] returns the string obtained by applying [f] to each
83    element of [l] and separating their output with [sep]. *)
84
85 val string_of_list: string -> ('a -> string) -> 'a list -> string