1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
include ListLabels
@BEGIN_BEFORE_4_08_0@
let filter_map ~f l =
Stdcompat__list.filter_map f l
@END_BEFORE_4_08_0@
@BEGIN_BEFORE_4_00_0@
let iteri ~f l =
Stdcompat__list.iteri f l
let mapi ~f l =
Stdcompat__list.mapi f l
@END_BEFORE_4_00_0@
@BEGIN_BEFORE_4_03_0@
let rec uniq_rev_append cmp l accu =
match l with
| [] -> accu
| [item] -> item :: accu
| hd :: (hd' :: _ as tl) ->
if cmp hd hd' = 0 then uniq_rev_append cmp tl accu
else uniq_rev_append cmp tl (hd :: accu)
let sort_uniq ~cmp l =
let cmp' a b = - (cmp a b) in
let rev_l = sort cmp' l in
uniq_rev_append cmp rev_l []
@END_BEFORE_4_03_0@
@BEGIN_BEFORE_4_05_0@
let cons x xs =
x :: xs
let rec compare_lengths l l' =
match l, l' with
| [], [] -> 0
| [], _ -> -1
| _, [] -> 1
| _ :: tl, _ :: tl' ->
compare_lengths tl tl'
let rec compare_length_with l ~len =
if len < 0 then 1
else if len = 0 then
if l = [] then 0
else 1
else
match l with
| [] -> -1
| _ :: tl -> compare_length_with tl ~len:(pred len)
let nth_opt l n =
Stdcompat__tools.option_find (nth l) n
let find_opt ~f l =
try
Stdcompat__tools.option_find
(find ~f:(Stdcompat__tools.pickle_predicate_not_found f)) l
with Stdcompat__tools.Predicate_not_found ->
raise Not_found
let assoc_opt key l =
Stdcompat__tools.option_find (assoc key) l
let assq_opt key l =
Stdcompat__tools.option_find (assq key) l
@END_BEFORE_4_05_0@
@BEGIN_BEFORE_4_06_0@
let init ~len ~f = Stdcompat__list.init len f
@END_BEFORE_4_06_0@
@BEGIN_BEFORE_4_07_0@
let to_seq = Stdcompat__list.to_seq
let of_seq = Stdcompat__list.of_seq
@END_BEFORE_4_07_0@
@BEGIN_BEFORE_4_08_0@
type 'a t = 'a list
@BEGIN_FROM_4_03_0@
= [] | (::) of 'a * 'a list
@END_FROM_4_03_0@
@END_BEFORE_4_08_0@
|