package stdcompat

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file stdcompat__listLabels.ml

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

(*
let filter_map ~f l =
  Stdcompat__list.filter_map f l
*)

(*
let iteri ~f l =
  Stdcompat__list.iteri f l

let mapi ~f l =
  Stdcompat__list.mapi f l
*)

(*
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 []
*)

(*
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
*)

(*
let init ~len ~f = Stdcompat__list.init len f
*)

(*
let to_seq = Stdcompat__list.to_seq

let of_seq = Stdcompat__list.of_seq
*)

(*
type 'a t = 'a list

   = [] | (::) of 'a * 'a list

*)