1Misc.Stdlib.List(3) OCaml library Misc.Stdlib.List(3)
2
3
4
6 Misc.Stdlib.List - no description
7
9 Module Misc.Stdlib.List
10
12 Module List
13 : sig end
14
15
16
17
18
19
20
21 type 'a t = 'a list
22
23
24
25
26
27 val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
28
29 The lexicographic order supported by the provided order. There is no
30 constraint on the relative lengths of the lists.
31
32
33
34 val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
35
36 Returns true if and only if the given lists have the same length and
37 content with respect to the given equality function.
38
39
40
41 val some_if_all_elements_are_some : 'a option t -> 'a t option
42
43 If all elements of the given list are Some _ then Some xs is returned
44 with the xs being the contents of those Some s, with order preserved.
45 Otherwise return None .
46
47
48
49 val map2_prefix : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t * 'b t
50
51
52 let r1, r2 = map2_prefix f l1 l2 If l1 is of length n and l2 = h2 @ t2
53 with h2 of length n, r1 is List.map2 f l1 h1 and r2 is t2.
54
55
56
57 val split_at : int -> 'a t -> 'a t * 'a t
58
59
60 split_at n l returns the pair before, after where before is the n first
61 elements of l and after the remaining ones. If l has less than n ele‐
62 ments, raises Invalid_argument.
63
64
65
66 val is_prefix : equal:('a -> 'a -> bool) -> 'a list -> of_:'a list ->
67 bool
68
69 Returns true if and only if the given list, with respect to the given
70 equality function on list members, is a prefix of the list of_ .
71
72
73 type 'a longest_common_prefix_result = private {
74 longest_common_prefix : 'a list ;
75 first_without_longest_common_prefix : 'a list ;
76 second_without_longest_common_prefix : 'a list ;
77 }
78
79
80
81
82
83 val find_and_chop_longest_common_prefix : equal:('a -> 'a -> bool) ->
84 first:'a list -> second:'a list -> 'a longest_common_prefix_result
85
86 Returns the longest list that, with respect to the provided equality
87 function, is a prefix of both of the given lists. The input lists,
88 each with such longest common prefix removed, are also returned.
89
90
91
92
93
94OCamldoc 2023-07-20 Misc.Stdlib.List(3)