package core

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

This module extends Base.List with bin_io and quickcheck.

The interface from Base

val compare : 'a Base__Ppx_compare_lib.compare -> 'a list Base__Ppx_compare_lib.compare
val globalize : ('a -> 'a) -> 'a list -> 'a list
val hash_fold_t : 'a Base__Ppx_hash_lib.hash_fold -> 'a list Base__Ppx_hash_lib.hash_fold
val t_of_sexp : (Sexplib0__.Sexp.t -> 'a) -> Sexplib0__.Sexp.t -> 'a list
val sexp_of_t : ('a -> Sexplib0__.Sexp.t) -> 'a list -> Sexplib0__.Sexp.t
val t_sexp_grammar : 'a Sexplib0.Sexp_grammar.t -> 'a list Sexplib0.Sexp_grammar.t
val of_list : 'a list -> 'a list
val of_array : 'a array -> 'a list
val append : 'a list -> 'a list -> 'a list
val concat : 'a list list -> 'a list
val filter : 'a list -> f:('a -> bool) -> 'a list
val filter_map : 'a list -> f:('a -> 'b option) -> 'b list
val concat_map : 'a list -> f:('a -> 'b list) -> 'b list
val partition_tf : 'a list -> f:('a -> bool) -> 'a list * 'a list
val partition_map : 'a list -> f:('a -> ('b, 'c) Base__.Either0.t) -> 'b list * 'c list
val mem : 'a list -> 'a -> equal:('a -> 'a -> bool) -> bool
val length : 'a list -> int
val is_empty : 'a list -> bool
val iter : 'a list -> f:('a -> unit) -> unit
val fold : 'a list -> init:'acc -> f:('acc -> 'a -> 'acc) -> 'acc
val fold_result : 'a list -> init:'acc -> f:('acc -> 'a -> ('acc, 'e) Base__.Result.t) -> ('acc, 'e) Base__.Result.t
val fold_until : 'a list -> init:'acc -> f:('acc -> 'a -> ('acc, 'final) Base__Container_intf.Continue_or_stop.t) -> finish:('acc -> 'final) -> 'final
val exists : 'a list -> f:('a -> bool) -> bool
val for_all : 'a list -> f:('a -> bool) -> bool
val count : 'a list -> f:('a -> bool) -> int
val sum : (module Base__Container_intf.Summable with type t = 'sum) -> 'a list -> f:('a -> 'sum) -> 'sum
val find : 'a list -> f:('a -> bool) -> 'a option
val find_map : 'a list -> f:('a -> 'b option) -> 'b option
val to_list : 'a list -> 'a list
val to_array : 'a list -> 'a array
val min_elt : 'a list -> compare:('a -> 'a -> int) -> 'a option
val max_elt : 'a list -> compare:('a -> 'a -> int) -> 'a option
val foldi : ('a list, 'a, 'b) Base__Indexed_container_intf.foldi
val iteri : ('a list, 'a) Base__Indexed_container_intf.iteri
val existsi : 'a list -> f:(int -> 'a -> bool) -> bool
val for_alli : 'a list -> f:(int -> 'a -> bool) -> bool
val counti : 'a list -> f:(int -> 'a -> bool) -> int
val findi : 'a list -> f:(int -> 'a -> bool) -> (int * 'a) option
val find_mapi : 'a list -> f:(int -> 'a -> 'b option) -> 'b option
val init : int -> f:(int -> 'a) -> 'a list
val mapi : 'a list -> f:(int -> 'a -> 'b) -> 'b list
val filteri : 'a list -> f:(int -> 'a -> bool) -> 'a list
val filter_mapi : 'a list -> f:(int -> 'a -> 'b option) -> 'b list
val concat_mapi : 'a list -> f:(int -> 'a -> 'b list) -> 'b list
val invariant : 'a Base__Invariant_intf.inv -> 'a list Base__Invariant_intf.inv
module Cartesian_product : sig ... end
val (>>=) : 'a list -> ('a -> 'b list) -> 'b list
val (>>|) : 'a list -> ('a -> 'b) -> 'b list
module Monad_infix : sig ... end
val bind : 'a list -> f:('a -> 'b list) -> 'b list
val return : 'a -> 'a list
val map : 'a list -> f:('a -> 'b) -> 'b list
val join : 'a list list -> 'a list
val ignore_m : 'a list -> unit list
val all : 'a list list -> 'a list list
val all_unit : unit list list -> unit list
module Let_syntax : sig ... end
module Or_unequal_lengths : sig ... end
val nth : 'a list -> int -> 'a option
val nth_exn : 'a list -> int -> 'a
val rev : 'a list -> 'a list
val rev_append : 'a list -> 'a list -> 'a list
val unordered_append : 'a list -> 'a list -> 'a list
val rev_map : 'a list -> f:('a -> 'b) -> 'b list
val iter2_exn : 'a list -> 'b list -> f:('a -> 'b -> unit) -> unit
val iter2 : 'a list -> 'b list -> f:('a -> 'b -> unit) -> unit Or_unequal_lengths.t
val rev_map2_exn : 'a list -> 'b list -> f:('a -> 'b -> 'c) -> 'c list
val rev_map2 : 'a list -> 'b list -> f:('a -> 'b -> 'c) -> 'c list Or_unequal_lengths.t
val fold2_exn : 'a list -> 'b list -> init:'acc -> f:('acc -> 'a -> 'b -> 'acc) -> 'acc
val fold2 : 'a list -> 'b list -> init:'acc -> f:('acc -> 'a -> 'b -> 'acc) -> 'acc Or_unequal_lengths.t
val fold_right2_exn : 'a list -> 'b list -> f:('a -> 'b -> 'acc -> 'acc) -> init:'acc -> 'acc
val fold_right2 : 'a list -> 'b list -> f:('a -> 'b -> 'acc -> 'acc) -> init:'acc -> 'acc Or_unequal_lengths.t
val for_all2_exn : 'a list -> 'b list -> f:('a -> 'b -> bool) -> bool
val for_all2 : 'a list -> 'b list -> f:('a -> 'b -> bool) -> bool Or_unequal_lengths.t
val exists2_exn : 'a list -> 'b list -> f:('a -> 'b -> bool) -> bool
val exists2 : 'a list -> 'b list -> f:('a -> 'b -> bool) -> bool Or_unequal_lengths.t
val rev_filter : 'a list -> f:('a -> bool) -> 'a list
val partition3_map : 'a list -> f:('a -> [ `Fst of 'b | `Snd of 'c | `Trd of 'd ]) -> 'b list * 'c list * 'd list
val partition_result : ('ok, 'error) Base__.Result.t list -> 'ok list * 'error list
val split_n : 'a list -> int -> 'a list * 'a list
val sort : 'a list -> compare:('a -> 'a -> int) -> 'a list
val stable_sort : 'a list -> compare:('a -> 'a -> int) -> 'a list
val merge : 'a list -> 'a list -> compare:('a -> 'a -> int) -> 'a list
val hd : 'a list -> 'a option
val tl : 'a list -> 'a list option
val hd_exn : 'a list -> 'a
val tl_exn : 'a list -> 'a list
val findi_exn : 'a list -> f:(int -> 'a -> bool) -> int * 'a
val find_exn : 'a list -> f:('a -> bool) -> 'a
val find_map_exn : 'a list -> f:('a -> 'b option) -> 'b
val find_mapi_exn : 'a list -> f:(int -> 'a -> 'b option) -> 'b
val folding_map : 'a list -> init:'acc -> f:('acc -> 'a -> 'acc * 'b) -> 'b list
val folding_mapi : 'a list -> init:'acc -> f:(int -> 'acc -> 'a -> 'acc * 'b) -> 'b list
val fold_map : 'a list -> init:'acc -> f:('acc -> 'a -> 'acc * 'b) -> 'acc * 'b list
val fold_mapi : 'a list -> init:'acc -> f:(int -> 'acc -> 'a -> 'acc * 'b) -> 'acc * 'b list
val map2_exn : 'a list -> 'b list -> f:('a -> 'b -> 'c) -> 'c list
val map2 : 'a list -> 'b list -> f:('a -> 'b -> 'c) -> 'c list Or_unequal_lengths.t
val rev_map3_exn : 'a list -> 'b list -> 'c list -> f:('a -> 'b -> 'c -> 'd) -> 'd list
val rev_map3 : 'a list -> 'b list -> 'c list -> f:('a -> 'b -> 'c -> 'd) -> 'd list Or_unequal_lengths.t
val map3_exn : 'a list -> 'b list -> 'c list -> f:('a -> 'b -> 'c -> 'd) -> 'd list
val map3 : 'a list -> 'b list -> 'c list -> f:('a -> 'b -> 'c -> 'd) -> 'd list Or_unequal_lengths.t
val rev_map_append : 'a list -> 'b list -> f:('a -> 'b) -> 'b list
val fold_right : 'a list -> f:('a -> 'acc -> 'acc) -> init:'acc -> 'acc
val fold_left : 'a list -> init:'acc -> f:('acc -> 'a -> 'acc) -> 'acc
val unzip : ('a * 'b) list -> 'a list * 'b list
val unzip3 : ('a * 'b * 'c) list -> 'a list * 'b list * 'c list
val zip : 'a list -> 'b list -> ('a * 'b) list Or_unequal_lengths.t
val zip_exn : 'a list -> 'b list -> ('a * 'b) list
val rev_mapi : 'a list -> f:(int -> 'a -> 'b) -> 'b list
val reduce_exn : 'a list -> f:('a -> 'a -> 'a) -> 'a
val reduce : 'a list -> f:('a -> 'a -> 'a) -> 'a option
val reduce_balanced : 'a list -> f:('a -> 'a -> 'a) -> 'a option
val reduce_balanced_exn : 'a list -> f:('a -> 'a -> 'a) -> 'a
val group : 'a list -> break:('a -> 'a -> bool) -> 'a list list
val groupi : 'a list -> break:(int -> 'a -> 'a -> bool) -> 'a list list
val sort_and_group : 'a list -> compare:('a -> 'a -> int) -> 'a list list
val chunks_of : 'a list -> length:int -> 'a list list
val last : 'a list -> 'a option
val last_exn : 'a list -> 'a
val is_prefix : 'a list -> prefix:'a list -> equal:('a -> 'a -> bool) -> bool
val is_suffix : 'a list -> suffix:'a list -> equal:('a -> 'a -> bool) -> bool
val find_consecutive_duplicate : 'a list -> equal:('a -> 'a -> bool) -> ('a * 'a) option
val remove_consecutive_duplicates : ?which_to_keep:[ `First | `Last ] -> 'a list -> equal:('a -> 'a -> bool) -> 'a list
val dedup_and_sort : 'a list -> compare:('a -> 'a -> int) -> 'a list
val find_a_dup : 'a list -> compare:('a -> 'a -> int) -> 'a option
val contains_dup : 'a list -> compare:('a -> 'a -> int) -> bool
val find_all_dups : 'a list -> compare:('a -> 'a -> int) -> 'a list
val all_equal : 'a list -> equal:('a -> 'a -> bool) -> 'a option
val range : ?stride:int -> ?start:[ `exclusive | `inclusive ] -> ?stop:[ `exclusive | `inclusive ] -> int -> int -> int list
val range' : compare:('a -> 'a -> int) -> stride:('a -> 'a) -> ?start:[ `exclusive | `inclusive ] -> ?stop:[ `exclusive | `inclusive ] -> 'a -> 'a -> 'a list
val rev_filter_map : 'a list -> f:('a -> 'b option) -> 'b list
val rev_filter_mapi : 'a list -> f:(int -> 'a -> 'b option) -> 'b list
val filter_opt : 'a option list -> 'a list
val sub : 'a list -> pos:int -> len:int -> 'a list
val take : 'a list -> int -> 'a list
val drop : 'a list -> int -> 'a list
val take_while : 'a list -> f:('a -> bool) -> 'a list
val drop_while : 'a list -> f:('a -> bool) -> 'a list
val split_while : 'a list -> f:('a -> bool) -> 'a list * 'a list
val drop_last : 'a list -> 'a list option
val drop_last_exn : 'a list -> 'a list
val concat_no_order : 'a list list -> 'a list
val cons : 'a -> 'a list -> 'a list
val cartesian_product : 'a list -> 'b list -> ('a * 'b) list
val permute : ?random_state:Base__.Random.State.t -> 'a list -> 'a list
val random_element : ?random_state:Base__.Random.State.t -> 'a list -> 'a option
val random_element_exn : ?random_state:Base__.Random.State.t -> 'a list -> 'a
val is_sorted : 'a list -> compare:('a -> 'a -> int) -> bool
val is_sorted_strictly : 'a list -> compare:('a -> 'a -> int) -> bool
val equal : ('a -> 'a -> bool) -> 'a list -> 'a list -> bool
module Infix : sig ... end
val transpose : 'a list list -> 'a list list option
val transpose_exn : 'a list list -> 'a list list
val intersperse : 'a list -> sep:'a -> 'a list
type 'a t = 'a Base.List.t
include Bin_prot.Binable.S1 with type 'a t := 'a t
val bin_shape_t : Bin_prot.Shape.t -> Bin_prot.Shape.t
val bin_size_t : ('a, 'a t) Bin_prot.Size.sizer1
val bin_write_t : ('a, 'a t) Bin_prot.Write.writer1
val bin_read_t : ('a, 'a t) Bin_prot.Read.reader1
val __bin_read_t__ : ('a, int -> 'a t) Bin_prot.Read.reader1
val bin_writer_t : ('a, 'a t) Bin_prot.Type_class.S1.writer
val bin_reader_t : ('a, 'a t) Bin_prot.Type_class.S1.reader
val bin_t : ('a, 'a t) Bin_prot.Type_class.S1.t
include Typerep_lib.Typerepable.S1 with type 'a t := 'a t
val typerep_of_t : 'a Typerep_lib.Std_internal.Typerep.t -> 'a t Typerep_lib.Std_internal.Typerep.t
val typename_of_t : 'a Typerep_lib.Typename.t -> 'a t Typerep_lib.Typename.t
module Assoc : sig ... end

Extensions

val stable_dedup_staged : compare:('a -> 'a -> Base.Int.t) -> ('a Base.List.t -> 'a Base.List.t) Core__.Import.Staged.t

stable_dedup_staged is the same as dedup_and_sort but maintains the order of the list. This function is staged because it instantiates a functor when compare is passed.

See also Set.stable_dedup_list, which is the underlying implementation of this function and lets you avoid the functor instantiation when you already have such a module on hand.

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
include Quickcheckable.S1 with type 'a t := 'a t
val quickcheck_generator : 'a Base_quickcheck.Generator.t -> 'a t Base_quickcheck.Generator.t
val quickcheck_observer : 'a Base_quickcheck.Observer.t -> 'a t Base_quickcheck.Observer.t
val quickcheck_shrinker : 'a Base_quickcheck.Shrinker.t -> 'a t Base_quickcheck.Shrinker.t
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_filtered : 'a t -> 'a t Quickcheck.Generator.t

Randomly drops elements from the input list. Length is chosen uniformly between 0 and the length of the input, inclusive.

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.

val zip_with_remainder : 'a Base.List.t -> 'b Base.List.t -> ('a * 'b) Base.List.t * ('a Base.List.t, 'b Base.List.t) Either.t Base.Option.t

zip_with_remainder xs ys zips as many elements as possible of xs and ys together and also returns the un-zipped remainder of the longer input, if the inputs have different lengths.

If xs and ys have the same length, zip_with_remainder xs ys returns the same thing as (zip_exn xs ys, None)

module Stable : sig ... end
OCaml

Innovation. Community. Security.