package base
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
Full standard library replacement for OCaml
Install
dune-project
Dependency
Authors
Maintainers
Sources
v0.17.3.tar.gz
md5=2100b0ed13fecf43be86ed45c5b2cc4d
sha512=628610caff7e124631870fa1e29661caac28bdfdb18750ee43b868037da3d65d6dd9023b4be7c4c52405679efb5e865a6632d95606a22b28a36636a6bf706ef3
doc/src/base/list0.ml.html
Source file list0.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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123(* [List0] defines list functions that are primitives or can be simply defined in terms of [Stdlib.List]. [List0] is intended to completely express the part of [Stdlib.List] that [Base] uses -- no other file in Base other than list0.ml should use [Stdlib.List]. [List0] has few dependencies, and so is available early in Base's build order. All Base files that need to use lists and come before [Base.List] in build order should do [module List = List0]. Defining [module List = List0] is also necessary because it prevents ocamldep from mistakenly causing a file to depend on [Base.List]. *) open! Import0 let hd_exn = Stdlib.List.hd let rev_append = Stdlib.List.rev_append let tl_exn = Stdlib.List.tl let unzip = Stdlib.List.split (* Some of these are eta expanded in order to permute parameter order to follow Base conventions. *) let length = let rec length_aux len = function | [] -> len | _ :: l -> length_aux (len + 1) l in fun l -> length_aux 0 l ;; let rec exists t ~f = match t with | [] -> false | x :: xs -> if f x then true else exists xs ~f ;; let rec exists2_ok l1 l2 ~(f : _ -> _ -> _) = match l1, l2 with | [], [] -> false | a1 :: l1, a2 :: l2 -> f a1 a2 || exists2_ok l1 l2 ~f | _, _ -> invalid_arg "List.exists2" ;; let rec fold t ~init ~(f : _ -> _ -> _) = match t with | [] -> init | a :: l -> fold l ~init:(f init a) ~f ;; let rec fold2_ok l1 l2 ~init ~(f : _ -> _ -> _ -> _) = match l1, l2 with | [], [] -> init | a1 :: l1, a2 :: l2 -> fold2_ok l1 l2 ~f ~init:(f init a1 a2) | _, _ -> invalid_arg "List.fold_left2" ;; let for_all t ~f = not (exists t ~f:(fun x -> not (f x))) let rec for_all2_ok l1 l2 ~(f : _ -> _ -> _) = match l1, l2 with | [], [] -> true | a1 :: l1, a2 :: l2 -> f a1 a2 && for_all2_ok l1 l2 ~f | _, _ -> invalid_arg "List.for_all2" ;; let rec iter t ~(f : _ -> _) = match t with | [] -> () | a :: l -> f a; iter l ~f ;; let rec iter2_ok l1 l2 ~(f : _ -> _ -> unit) = match l1, l2 with | [], [] -> () | a1 :: l1, a2 :: l2 -> f a1 a2; iter2_ok l1 l2 ~f | _, _ -> invalid_arg "List.iter2" ;; let rec nontail_map t ~f = match t with | [] -> [] | x :: xs -> let y = f x in y :: nontail_map xs ~f ;; let nontail_mapi t ~f = Stdlib.List.mapi t ~f let partition t ~f = Stdlib.List.partition t ~f let rev_map = let rec rmap_f f accu = function | [] -> accu | a :: l -> rmap_f f (f a :: accu) l in fun l ~f -> rmap_f f [] l ;; let rev_map2_ok = let rec rmap2_f f accu l1 l2 = match l1, l2 with | [], [] -> accu | a1 :: l1, a2 :: l2 -> rmap2_f f (f a1 a2 :: accu) l1 l2 | _, _ -> invalid_arg "List.rev_map2" in fun l1 l2 ~(f : _ -> _ -> _) -> rmap2_f f [] l1 l2 ;; let rev = function | ([] | [ _ ]) as res -> res | x :: y :: rest -> rev_append rest [ y; x ] ;; let fold_right l ~(f : _ -> _ -> _) ~init = match l with | [] -> init (* avoid the allocation of [~f] below *) | _ -> fold ~f:(fun a b -> f b a) ~init (rev l) [@nontail] ;; let fold_right2_ok l1 l2 ~(f : _ -> _ -> _ -> _) ~init = match l1, l2 with | [], [] -> init (* avoid the allocation of [~f] below *) | _, _ -> fold2_ok ~f:(fun a b c -> f b c a) ~init (rev l1) (rev l2) [@nontail] ;;
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>