[486] | 1 | |
---|
[740] | 2 | (** This module provides some additional functions on lists or arithmetics. *) |
---|
[486] | 3 | |
---|
[818] | 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 |
---|
[1584] | 12 | val fold3_right : ('a -> 'b -> 'c -> 'd -> 'd) -> |
---|
| 13 | 'a list -> 'b list -> 'c list -> 'd -> 'd |
---|
[818] | 14 | |
---|
[740] | 15 | val max_list : 'a list -> 'a |
---|
| 16 | |
---|
| 17 | val pow : int -> int -> int |
---|
| 18 | |
---|
[486] | 19 | val make: 'a -> int -> 'a list |
---|
| 20 | |
---|
[1584] | 21 | val makei : (int -> 'a) -> int -> 'a list |
---|
| 22 | |
---|
[486] | 23 | val index_of : 'a -> 'a list -> int |
---|
| 24 | |
---|
[740] | 25 | val foldi_until : int -> (int -> 'a -> 'b -> 'a) -> 'a -> 'b list -> 'a |
---|
| 26 | |
---|
[619] | 27 | val foldi : (int -> 'a -> 'b -> 'a) -> 'a -> 'b list -> 'a |
---|
[486] | 28 | |
---|
[619] | 29 | val iteri : (int -> 'a -> unit) -> 'a list -> unit |
---|
[486] | 30 | |
---|
[619] | 31 | val mapi : (int -> 'a -> 'b) -> 'a list -> 'b list |
---|
[486] | 32 | |
---|
[619] | 33 | (* Raises Not_found if the list is empty. *) |
---|
| 34 | val last : 'a list -> 'a |
---|
| 35 | |
---|
| 36 | (* [split l i] splits the list [l] in two lists: one with the elements |
---|
[486] | 37 | up until the [i]th (exclusive) and one with the rest. *) |
---|
| 38 | val split: 'a list -> int -> ('a list * 'a list) |
---|
| 39 | |
---|
[619] | 40 | (* [split_last l] returns the list [l] without its last element and its last |
---|
| 41 | element. Raises Invalid_argument "MiscPottier.split_last" if the list is |
---|
| 42 | empty. *) |
---|
| 43 | val split_last : 'a list -> ('a list * 'a) |
---|
| 44 | |
---|
[486] | 45 | val update_list_assoc: 'a -> 'b -> ('a * 'b) list -> ('a * 'b) list |
---|
| 46 | |
---|
| 47 | (* Pasted from Pottier's PP compiler *) |
---|
| 48 | |
---|
| 49 | (* [combine] turns a pair of lists into a list of pairs. It never |
---|
| 50 | fails: the length of the output list is the minimum of the lengths |
---|
| 51 | of the input lists. *) |
---|
| 52 | |
---|
| 53 | val combine: 'a list -> 'b list -> ('a * 'b) list |
---|
| 54 | |
---|
| 55 | (* [subtract xs1 xs2] returns the list [xs1] deprived of as many |
---|
| 56 | elements as there are in the list [xs2]. *) |
---|
| 57 | |
---|
| 58 | val subtract: 'a list -> 'b list -> 'a list |
---|
| 59 | |
---|
| 60 | (* [mirror] reverses the order of the pair components in a list |
---|
| 61 | of pairs. *) |
---|
| 62 | |
---|
| 63 | val mirror: ('a * 'b) list -> ('b * 'a) list |
---|
| 64 | |
---|
| 65 | (* [length l] is the length of the list [l]. *) |
---|
| 66 | |
---|
| 67 | val length: 'a list -> int32 |
---|
| 68 | |
---|
| 69 | (* [prefix k xs] returns the prefix of length [k] of the list [xs]. |
---|
| 70 | If [xs] has length less than [k], [xs] is returned. *) |
---|
| 71 | |
---|
| 72 | val prefix: int -> 'a list -> 'a list |
---|
| 73 | |
---|
| 74 | (* [memoize f] produces a memoizing version of the function [f]. |
---|
| 75 | It requires the domain of [f] to support generic equality. *) |
---|
| 76 | |
---|
| 77 | val memoize: ('a -> 'b) -> ('a -> 'b) |
---|
| 78 | |
---|
| 79 | (* [filter_map filter map l] returns the list [l] where elements satisfying the |
---|
| 80 | [filter] function have been replaced by their application to the [map] |
---|
| 81 | function. Elements that do not satisfy [filter] are not in the result |
---|
| 82 | list. *) |
---|
| 83 | |
---|
| 84 | val filter_map: ('a -> bool) -> ('a -> 'b) -> 'a list -> 'b list |
---|
| 85 | |
---|
| 86 | (* [string_of_list sep f l] returns the string obtained by applying [f] to each |
---|
| 87 | element of [l] and separating their output with [sep]. *) |
---|
| 88 | |
---|
| 89 | val string_of_list: string -> ('a -> string) -> 'a list -> string |
---|
[1584] | 90 | |
---|
| 91 | (* [sublist h k l] gives the sublist of [l] starting from index [h] to |
---|
| 92 | [k] excluded. Can raise [Invalid_argument "sublist: invalid interval"]. *) |
---|
| 93 | val sublist : 'a list -> int -> int -> 'a list |
---|
| 94 | |
---|
| 95 | (* [fill l n] makes a list of length [n] using elements from [l], possibly |
---|
| 96 | repeating it. Raises Invalid_argument if [n < 0] or [l = []]. *) |
---|
| 97 | val fill : 'a list -> int -> 'a list |
---|
| 98 | |
---|