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 iff the given lists have the same length and content with
37 respect to the given equality function.
38
39
40
41 val find_map : ('a -> 'b option) -> 'a t -> 'b option
42
43
44 find_map f l returns the first evaluation of f that returns Some , or
45 returns None if there is no such element.
46
47
48
49 val some_if_all_elements_are_some : 'a option t -> 'a t option
50
51 If all elements of the given list are Some _ then Some xs is returned
52 with the xs being the contents of those Some s, with order preserved.
53 Otherwise return None .
54
55
56
57 val map2_prefix : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t * 'b t
58
59
60 let r1, r2 = map2_prefix f l1 l2 If l1 is of length n and l2 = h2 @ t2
61 with h2 of length n, r1 is List.map2 f l1 h1 and r2 is t2.
62
63
64
65 val split_at : int -> 'a t -> 'a t * 'a t
66
67
68 split_at n l returns the pair before, after where before is the n first
69 elements of l and after the remaining ones. If l has less than n ele‐
70 ments, raises Invalid_argument.
71
72
73
74 val is_prefix : equal:('a -> 'a -> bool) -> 'a list -> of_:'a list ->
75 bool
76
77 Returns true iff the given list, with respect to the given equality
78 function on list members, is a prefix of the list of_ .
79
80
81 type 'a longest_common_prefix_result = private {
82 longest_common_prefix : 'a list ;
83 first_without_longest_common_prefix : 'a list ;
84 second_without_longest_common_prefix : 'a list ;
85 }
86
87
88
89
90
91 val find_and_chop_longest_common_prefix : equal:('a -> 'a -> bool) ->
92 first:'a list -> second:'a list -> 'a longest_common_prefix_result
93
94 Returns the longest list that, with respect to the provided equality
95 function, is a prefix of both of the given lists. The input lists,
96 each with such longest common prefix removed, are also returned.
97
98
99
100
101
102OCamldoc 2020-02-27 Misc.Stdlib.List(3)