package core_kernel

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

This module extends Base.List with bin_io and quickcheck.

type 'a t = 'a Base.List.t
include sig ... end
val bin_t : 'a Bin_prot.Type_class.t -> 'a t Bin_prot.Type_class.t
val bin_read_t : 'a Bin_prot.Read.reader -> 'a t Bin_prot.Read.reader
val __bin_read_t__ : 'a Bin_prot.Read.reader -> (Base.Int.t -> 'a t) Bin_prot.Read.reader
val bin_reader_t : 'a Bin_prot.Type_class.reader -> 'a t Bin_prot.Type_class.reader
val bin_size_t : 'a Bin_prot.Size.sizer -> 'a t Bin_prot.Size.sizer
val bin_write_t : 'a Bin_prot.Write.writer -> 'a t Bin_prot.Write.writer
val bin_writer_t : 'a Bin_prot.Type_class.writer -> 'a t Bin_prot.Type_class.writer
val bin_shape_t : Bin_prot.Shape.t -> Bin_prot.Shape.t
val typerep_of_t : 'a Typerep_lib.Std.Typerep.t -> 'a t Typerep_lib.Std.Typerep.t
val typename_of_t : 'a Typerep_lib.Std.Typename.t -> 'a t Typerep_lib.Std.Typename.t
module Assoc : sig ... end

The interface from Base

include module type of struct include Base.List end with type 'a t := 'a t with module Assoc := Base.List.Assoc
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
val hash_fold_t : (Base__.Ppx_hash_lib.Std.Hash.state -> 'a -> Base__.Ppx_hash_lib.Std.Hash.state) -> Base__.Ppx_hash_lib.Std.Hash.state -> 'a t -> Base__.Ppx_hash_lib.Std.Hash.state
val t_of_sexp : (Base__.Ppx_sexp_conv_lib.Sexp.t -> 'a) -> Base__.Ppx_sexp_conv_lib.Sexp.t -> 'a t
val sexp_of_t : ('a -> Base__.Ppx_sexp_conv_lib.Sexp.t) -> 'a t -> Base__.Ppx_sexp_conv_lib.Sexp.t
val mem : 'a t -> 'a -> equal:('a -> 'a -> bool) -> bool
val length : 'a t -> int
val is_empty : 'a t -> bool
val iter : 'a t -> f:('a -> unit) -> unit
val fold : 'a t -> init:'accum -> f:('accum -> 'a -> 'accum) -> 'accum
val fold_result : 'a t -> init:'accum -> f:('accum -> 'a -> ('accum, 'e) Base__.Result.t) -> ('accum, 'e) Base__.Result.t
val fold_until : 'a t -> init:'accum -> f:('accum -> 'a -> ('accum, 'final) Base__.Container_intf.Continue_or_stop.t) -> finish:('accum -> 'final) -> 'final
val exists : 'a t -> f:('a -> bool) -> bool
val for_all : 'a t -> f:('a -> bool) -> bool
val sum : (module Base__.Commutative_group.S with type t = 'sum) -> 'a t -> f:('a -> 'sum) -> 'sum
val find : 'a t -> f:('a -> bool) -> 'a option
val find_map : 'a t -> f:('a -> 'b option) -> 'b option
val to_list : 'a t -> 'a list
val to_array : 'a t -> 'a array
val min_elt : 'a t -> compare:('a -> 'a -> int) -> 'a option
val max_elt : 'a t -> compare:('a -> 'a -> int) -> 'a option
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t
val (>>|) : 'a t -> ('a -> 'b) -> 'b t
module Monad_infix = List.Monad_infix
val bind : 'a t -> f:('a -> 'b t) -> 'b t
val return : 'a -> 'a t
val join : 'a t t -> 'a t
val ignore_m : 'a t -> unit t
val all : 'a t list -> 'a list t
val all_unit : unit t list -> unit t
val all_ignore : unit t list -> unit t
  • deprecated [since 2018-02] Use [all_unit]
module Let_syntax = List.Let_syntax
module Or_unequal_lengths = List.Or_unequal_lengths
val of_list : 'a t -> 'a t
val nth : 'a t -> int -> 'a option
val nth_exn : 'a t -> int -> 'a
val rev : 'a t -> 'a t
val rev_append : 'a t -> 'a t -> 'a t
val unordered_append : 'a t -> 'a t -> 'a t
val rev_map : 'a t -> f:('a -> 'b) -> 'b t
val fold_left : 'a t -> init:'b -> f:('b -> 'a -> 'b) -> 'b
val iter2_exn : 'a t -> 'b t -> f:('a -> 'b -> unit) -> unit
val iter2 : 'a t -> 'b t -> f:('a -> 'b -> unit) -> unit Or_unequal_lengths.t
val rev_map2_exn : 'a t -> 'b t -> f:('a -> 'b -> 'c) -> 'c t
val rev_map2 : 'a t -> 'b t -> f:('a -> 'b -> 'c) -> 'c t Or_unequal_lengths.t
val fold2_exn : 'a t -> 'b t -> init:'c -> f:('c -> 'a -> 'b -> 'c) -> 'c
val fold2 : 'a t -> 'b t -> init:'c -> f:('c -> 'a -> 'b -> 'c) -> 'c Or_unequal_lengths.t
val for_alli : 'a t -> f:(int -> 'a -> bool) -> bool
val for_all2_exn : 'a t -> 'b t -> f:('a -> 'b -> bool) -> bool
val for_all2 : 'a t -> 'b t -> f:('a -> 'b -> bool) -> bool Or_unequal_lengths.t
val existsi : 'a t -> f:(int -> 'a -> bool) -> bool
val exists2_exn : 'a t -> 'b t -> f:('a -> 'b -> bool) -> bool
val exists2 : 'a t -> 'b t -> f:('a -> 'b -> bool) -> bool Or_unequal_lengths.t
val filter : 'a t -> f:('a -> bool) -> 'a t
val rev_filter : 'a t -> f:('a -> bool) -> 'a t
val filteri : 'a t -> f:(int -> 'a -> bool) -> 'a t
val partition_map : 'a t -> f:('a -> [ `Fst of 'b | `Snd of 'c ]) -> 'b t * 'c t
val partition3_map : 'a t -> f:('a -> [ `Fst of 'b | `Snd of 'c | `Trd of 'd ]) -> 'b t * 'c t * 'd t
val partition_tf : 'a t -> f:('a -> bool) -> 'a t * 'a t
val split_n : 'a t -> int -> 'a t * 'a t
val sort : compare:('a -> 'a -> int) -> 'a t -> 'a t
val stable_sort : compare:('a -> 'a -> int) -> 'a t -> 'a t
val merge : 'a t -> 'a t -> compare:('a -> 'a -> int) -> 'a t
val hd : 'a t -> 'a option
val tl : 'a t -> 'a t option
val hd_exn : 'a t -> 'a
val tl_exn : 'a t -> 'a t
val findi : 'a t -> f:(int -> 'a -> bool) -> (int * 'a) option
val find_exn : 'a t -> f:('a -> bool) -> 'a
val find_map_exn : 'a t -> f:('a -> 'b option) -> 'b
val find_mapi : 'a t -> f:(int -> 'a -> 'b option) -> 'b option
val find_mapi_exn : 'a t -> f:(int -> 'a -> 'b option) -> 'b
val append : 'a t -> 'a t -> 'a t
val map : 'a t -> f:('a -> 'b) -> 'b t
val folding_map : 'a t -> init:'b -> f:('b -> 'a -> 'b * 'c) -> 'c t
val folding_mapi : 'a t -> init:'b -> f:(int -> 'b -> 'a -> 'b * 'c) -> 'c t
val fold_map : 'a t -> init:'b -> f:('b -> 'a -> 'b * 'c) -> 'b * 'c t
val fold_mapi : 'a t -> init:'b -> f:(int -> 'b -> 'a -> 'b * 'c) -> 'b * 'c t
val concat_map : 'a t -> f:('a -> 'b t) -> 'b t
val concat_mapi : 'a t -> f:(int -> 'a -> 'b t) -> 'b t
val map2_exn : 'a t -> 'b t -> f:('a -> 'b -> 'c) -> 'c t
val map2 : 'a t -> 'b t -> f:('a -> 'b -> 'c) -> 'c t Or_unequal_lengths.t
val rev_map3_exn : 'a t -> 'b t -> 'c t -> f:('a -> 'b -> 'c -> 'd) -> 'd t
val rev_map3 : 'a t -> 'b t -> 'c t -> f:('a -> 'b -> 'c -> 'd) -> 'd t Or_unequal_lengths.t
val map3_exn : 'a t -> 'b t -> 'c t -> f:('a -> 'b -> 'c -> 'd) -> 'd t
val map3 : 'a t -> 'b t -> 'c t -> f:('a -> 'b -> 'c -> 'd) -> 'd t Or_unequal_lengths.t
val rev_map_append : 'a t -> 'b t -> f:('a -> 'b) -> 'b t
val fold_right : 'a t -> f:('a -> 'b -> 'b) -> init:'b -> 'b
val unzip : ('a * 'b) t -> 'a t * 'b t
val unzip3 : ('a * 'b * 'c) t -> 'a t * 'b t * 'c t
val zip : 'a t -> 'b t -> ('a * 'b) t option
val zip_exn : 'a t -> 'b t -> ('a * 'b) t
val mapi : 'a t -> f:(int -> 'a -> 'b) -> 'b t
val rev_mapi : 'a t -> f:(int -> 'a -> 'b) -> 'b t
val iteri : 'a t -> f:(int -> 'a -> unit) -> unit
val foldi : 'a t -> init:'b -> f:(int -> 'b -> 'a -> 'b) -> 'b
val reduce_exn : 'a t -> f:('a -> 'a -> 'a) -> 'a
val reduce : 'a t -> f:('a -> 'a -> 'a) -> 'a option
val reduce_balanced : 'a t -> f:('a -> 'a -> 'a) -> 'a option
val reduce_balanced_exn : 'a t -> f:('a -> 'a -> 'a) -> 'a
val group : 'a t -> break:('a -> 'a -> bool) -> 'a t t
val groupi : 'a t -> break:(int -> 'a -> 'a -> bool) -> 'a t t
val chunks_of : 'a t -> length:int -> 'a t t
val last : 'a t -> 'a option
val last_exn : 'a t -> 'a
val is_prefix : 'a t -> prefix:'a t -> equal:('a -> 'a -> bool) -> bool
val find_consecutive_duplicate : 'a t -> equal:('a -> 'a -> bool) -> ('a * 'a) option
val remove_consecutive_duplicates : ?which_to_keep:[ `First | `Last ] -> 'a t -> equal:('a -> 'a -> bool) -> 'a t
val dedup_and_sort : compare:('a -> 'a -> int) -> 'a t -> 'a t
val dedup : compare:('a -> 'a -> int) -> 'a t -> 'a t
  • deprecated [since 2017-04] Use [dedup_and_sort] instead
val find_a_dup : compare:('a -> 'a -> int) -> 'a t -> 'a option
val contains_dup : compare:('a -> 'a -> int) -> 'a t -> bool
val find_all_dups : compare:('a -> 'a -> int) -> 'a t -> 'a list
val count : 'a t -> f:('a -> bool) -> int
val counti : 'a t -> f:(int -> 'a -> bool) -> int
val range : ?stride:int -> ?start:[ `exclusive | `inclusive ] -> ?stop:[ `exclusive | `inclusive ] -> int -> int -> int t
val range' : compare:('a -> 'a -> int) -> stride:('a -> 'a) -> ?start:[ `exclusive | `inclusive ] -> ?stop:[ `exclusive | `inclusive ] -> 'a -> 'a -> 'a t
val init : int -> f:(int -> 'a) -> 'a t
val rev_filter_map : 'a t -> f:('a -> 'b option) -> 'b t
val rev_filter_mapi : 'a t -> f:(int -> 'a -> 'b option) -> 'b t
val filter_map : 'a t -> f:('a -> 'b option) -> 'b t
val filter_mapi : 'a t -> f:(int -> 'a -> 'b option) -> 'b t
val filter_opt : 'a option t -> 'a t
val sub : 'a t -> pos:int -> len:int -> 'a t
val take : 'a t -> int -> 'a t
val drop : 'a t -> int -> 'a t
val take_while : 'a t -> f:('a -> bool) -> 'a t
val drop_while : 'a t -> f:('a -> bool) -> 'a t
val split_while : 'a t -> f:('a -> bool) -> 'a t * 'a t
val concat : 'a t t -> 'a t
val concat_no_order : 'a t t -> 'a t
val cons : 'a -> 'a t -> 'a t
val cartesian_product : 'a t -> 'b t -> ('a * 'b) t
val permute : ?random_state:Base__.Random.State.t -> 'a t -> 'a t
val random_element : ?random_state:Base__.Random.State.t -> 'a t -> 'a option
val random_element_exn : ?random_state:Base__.Random.State.t -> 'a t -> 'a
val is_sorted : 'a t -> compare:('a -> 'a -> int) -> bool
val is_sorted_strictly : 'a t -> compare:('a -> 'a -> int) -> bool
val equal : 'a t -> 'a t -> equal:('a -> 'a -> bool) -> bool
module Infix = List.Infix
val transpose : 'a t t -> 'a t t option
val transpose_exn : 'a t t -> 'a t t
val intersperse : 'a t -> sep:'a -> 'a t

Extensions

val stable_dedup : 'a t -> 'a t

stable_dedup Same as dedup but maintains the order of the list and doesn't allow compare function to be specified (otherwise, the implementation in terms of Set.t would hide a heavyweight functor instantiation at each call).

val stable_dedup_staged : compare:('a -> 'a -> Base.Int.t) -> ('a Base.List.t -> 'a Base.List.t) Core_kernel__.Import.Staged.t
exception Duplicate_found of Base.Unit.t -> Base.Sexp.t * Base.String.t

Only raised in exn_if_dup below.

  • deprecated [since 2018-03] stop matching on Duplicate_found. [exn_if_dup] will eventually raise a different and unspecified exception
val exn_if_dup : compare:('a -> 'a -> Base.Int.t) -> ?context:Base.String.t -> 'a t -> to_sexp:('a -> Base.Sexp.t) -> Base.Unit.t

exn_if_dup ~compare ?context t ~to_sexp raises if t contains a duplicate. It will specifically raise a Duplicate_found exception and use context as its second argument. O(n log n) time complexity.

val slice : 'a t -> Base.Int.t -> Base.Int.t -> 'a t

slice t start stop returns a new list including elements t.(start) through t.(stop-1), normalized Python-style with the exception that stop = 0 is treated as stop = length t.

include Comparator.Derived with type 'a t := 'a t
type 'cmp comparator_witness
val comparator : ('a, 'cmp) Comparator.comparator -> ('a t, 'cmp comparator_witness) Comparator.comparator
val to_string : f:('a -> Base.String.t) -> 'a t -> Base.String.t
val gen_non_empty : 'a Quickcheck.Generator.t -> 'a t Quickcheck.Generator.t

Like gen, but never generates the empty list.

val gen_with_length : Base.Int.t -> 'a Quickcheck.Generator.t -> 'a t Quickcheck.Generator.t

Like gen, but generates lists with the given length.

val gen_permutations : 'a t -> 'a t Quickcheck.Generator.t

gen_permutations t generates all permutations of list. If t contains duplicate values, then gen_permutations t will produce duplicate lists.

OCaml

Innovation. Community. Security.