Module Stdlib.List

type t('a) = list('a);
let compare: ('a => 'a => int) => t('a) => t('a) => int;

The lexicographic order supported by the provided order. There is no constraint on the relative lengths of the lists.

let equal: ('a => 'a => bool) => t('a) => t('a) => bool;

Returns true if and only if the given lists have the same length and content with respect to the given equality function.

let some_if_all_elements_are_some: t(option('a)) => option(t('a));

If all elements of the given list are Some _ then Some xs is returned with the xs being the contents of those Somes, with order preserved. Otherwise return None.

let map2_prefix: ('a => 'b => 'c) => t('a) => t('b) => (t('c), t('b));

let r1, r2 = map2_prefix f l1 l2 If l1 is of length n and l2 = h2 @ t2 with h2 of length n, r1 is List.map2 f l1 h1 and r2 is t2.

let split_at: int => t('a) => (t('a), t('a));

split_at n l returns the pair before, after where before is the n first elements of l and after the remaining ones. If l has less than n elements, raises Invalid_argument.

let is_prefix: equal:('a => 'a => bool) => list('a) => of_:list('a) => bool;

Returns true if and only if the given list, with respect to the given equality function on list members, is a prefix of the list of_.

type longest_common_prefix_result('a) = pri {
  1. longest_common_prefix: list('a),
  2. first_without_longest_common_prefix: list('a),
  3. second_without_longest_common_prefix: list('a),
};
let find_and_chop_longest_common_prefix: equal:('a => 'a => bool) => first:list('a) => second:list('a) => longest_common_prefix_result('a);

Returns the longest list that, with respect to the provided equality function, is a prefix of both of the given lists. The input lists, each with such longest common prefix removed, are also returned.