Misc.Stdlib.List(3)
π NAME π
Misc.Stdlib.List β Extensions to the List module β¨ and yes bestie, this is the Misc.Stdlib.List(3) page from the OCaml library β we're literally about to go through every single extension, no skipping, no cap π
πΈ Module πΈ
ModuleβMisc.Stdlib.Listπ
β¨ Documentation β¨
Module List β : sig end π«Ά
π Extensions to the List module π
Okay so here's the whole squad of extensions to List. Every type and every val is right here, with all the details intact, because we do not leave the group chat on read ππ
type 'a t = 'a listβ the type is literally'a list, cute and simple πval compare : ('a -> 'a -> int) -> 'a t -> 'a t -> intβ this is the lexicographic order supported by the provided order. There is no constraint on the relative lengths of the lists. Slay π¦val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> boolβ Returnstrueif and only if the given lists have the same length and content with respect to the given equality function. periodt πval some_if_all_elements_are_some : 'a option t -> 'a t optionβ If all elements of the given list areSome _thenSome xsis returned with thexsbeing the contents of thoseSome s, with order preserved. Otherwise returnNone. πval map2_prefix : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t * 'b tβ here's the exact example vibe:
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. Yes, that's what the page says, bestie π«Άπ₯
val iteri2 : (int -> 'a -> 'b -> unit) -> 'a list -> 'b list -> unitβ Same asList.iter2, but the function is applied to the index of the element as first argument (counting from 0). iconic πval split_at : int -> 'a t -> 'a t * 'a tβsplit_at n lreturns the pairbefore, afterwherebeforeis thenfirst elements oflandafterthe remaining ones. Iflhas less thannelements, raisesInvalid_argument. πval chunks_of : int -> 'a t -> 'a t tβchunks_of n treturns a list of nonempty lists whose concatenation is equal to the original list. Every list hasnelements, except for possibly the last list, which may have fewer.chunks_ofraises ifn <= 0. πval is_prefix : equal:('a -> 'a -> bool) -> 'a list -> of_:'a list -> boolβ Returnstrueif and only if the given list, with respect to the given equality function on list members, is a prefix of the listof_. β¨
Then there's this private record type β yes, it's private, so it's giving "look but don't touch" energy π:
type 'a longest_common_prefix_result = private {
longest_common_prefix : 'a list ;
first_without_longest_common_prefix : 'a list ;
second_without_longest_common_prefix : 'a list ;
}
val find_and_chop_longest_common_prefix : equal:('a -> 'a -> bool) -> first:'a list -> second:'a list -> 'a longest_common_prefix_resultβ 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. π
That's the whole page, bestie. Brought to you by OCamldoc, dated 2026-06-22, and filed under Misc.Stdlib.List(3). slay, bye π
β¨
π¦ where this page comes from
- arch rolling: ocaml 5.5.0-1 Β· LGPL2.1 AND custom: QPL-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms