include Core.List
include Core_kernel__.Core_list
This module extends the Base List
module with bin_io and quickcheck
include sig ... end
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
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 ‑> (int ‑> '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
module Assoc = Core_kernel__.Core_list.Assoc
include module type of sig ... end with type a t := a t with module Assoc := Assoc
val t_of_sexp : (Base__.Sexplib.Sexp.t ‑> 'a) ‑> Base__.Sexplib.Sexp.t ‑> 'a t
val sexp_of_t : ('a ‑> Base__.Sexplib.Sexp.t) ‑> 'a t ‑> Base__.Sexplib.Sexp.t
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 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, 'stop) Base.Container_intf.Continue_or_stop.t) ‑> ('accum, 'stop) Base.Container_intf.Finished_or_stopped_early.t
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 ‑> cmp:('a ‑> 'a ‑> int) ‑> 'a option
val max_elt : 'a t ‑> cmp:('a ‑> 'a ‑> int) ‑> 'a option
module Monad_infix = Base__List.Monad_infix
val return : 'a ‑> 'a t
module Let_syntax = Base__List.Let_syntax
val nth : 'a t ‑> int ‑> 'a option
val nth_exn : 'a t ‑> int ‑> 'a
val fold_left : 'a t ‑> init:'b ‑> f:('b ‑> 'a ‑> 'b) ‑> 'b
val iter2 : 'a t ‑> 'b t ‑> f:('a ‑> 'b ‑> unit) ‑> unit Or_unequal_lengths.t
val rev_map2 : 'a t ‑> 'b t ‑> f:('a ‑> 'b ‑> 'c) ‑> 'c t Or_unequal_lengths.t
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 : 'a t ‑> 'b t ‑> f:('a ‑> 'b ‑> bool) ‑> bool Or_unequal_lengths.t
val existsi : 'a t ‑> f:(int ‑> 'a ‑> bool) ‑> bool
val exists2 : 'a t ‑> 'b t ‑> f:('a ‑> 'b ‑> bool) ‑> bool Or_unequal_lengths.t
val hd : 'a t ‑> 'a option
val hd_exn : 'a t ‑> 'a
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 map2 : 'a t ‑> 'b t ‑> f:('a ‑> 'b ‑> 'c) ‑> 'c t Or_unequal_lengths.t
val rev_map3 : 'a t ‑> 'b t ‑> 'c t ‑> f:('a ‑> 'b ‑> 'c ‑> 'd) ‑> 'd t Or_unequal_lengths.t
val map3 : 'a t ‑> 'b t ‑> 'c t ‑> f:('a ‑> 'b ‑> 'c ‑> 'd) ‑> 'd t Or_unequal_lengths.t
val fold_right : 'a t ‑> f:('a ‑> 'b ‑> 'b) ‑> init:'b ‑> 'b
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 last : 'a t ‑> 'a option
val last_exn : 'a t ‑> 'a
val find_consecutive_duplicate : 'a t ‑> equal:('a ‑> 'a ‑> bool) ‑> ('a * 'a) option
val contains_dup : ?compare:('a ‑> 'a ‑> int) ‑> 'a t ‑> bool
val find_a_dup : ?compare:('a ‑> 'a ‑> int) ‑> 'a t ‑> 'a option
val find_all_dups : ?compare:('a ‑> 'a ‑> int) ‑> 'a t ‑> 'a list
exception
Duplicate_found of unit ‑> Base.Sexp.t * string
val exn_if_dup : ?compare:('a ‑> 'a ‑> int) ‑> ?context:string ‑> 'a t ‑> to_sexp:('a ‑> Base.Sexp.t) ‑> unit
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
module Assoc = Base__List.Assoc
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
module Infix = Base__List.Infix
val to_string : f:('a ‑> string) ‑> 'a t ‑> string
val gen' : ?length:[ `Exactly of int | `At_least of int | `At_most of int | `Between_inclusive of int * int ] ‑> 'a Core_kernel.Quickcheck.Generator.t ‑> 'a t Core_kernel.Quickcheck.Generator.t
Quickcheck generator for lists with additional customization.
List.gen' t
produces a generator for arbitrary lists of values from t
.
~length:(`Exactly n)
produces only lists of length n
.~length:(`At_least n)
produces only lists of length n
or greater.~length:(`At_most n)
produces only lists of length n
or less.~length:(`Between_inclusive (m,n))
produces only lists of length k
such
that m <= k
and k <= n
.The lists in the output of list t
are generated uniquely, so long as the values in
t
are generated uniquely.
val gen_permutations : 'a t ‑> 'a t Core_kernel.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 stable_dedup : 'a list ‑> 'a list
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 ‑> Core_kernel__.Import.int) ‑> ('a Core_kernel__.Import.list ‑> 'a Core_kernel__.Import.list) Core_kernel__.Std_internal.Staged.t
include Extended_list
Extensions to Core.List
.
val of_option : 'a option ‑> 'a list
of_option o
returns a list that is empty if o
is None, otherwise it is a singleton
list. Useful to get filter_map-like behavior in the context of something like a
concat_map.
val set_inter : 'a list ‑> 'a list ‑> 'a list
set_inter l1 l2
returns a list without duplicates of all elements of l1 that are in l2
val set_diff : 'a list ‑> 'a list ‑> 'a list
set_diff l1 l2
returns a list of all elements of l1 that are not in l2
val classify : ?equal:('b ‑> 'b ‑> bool) ‑> f:('a ‑> 'b) ‑> 'a list ‑> ('b * 'a list) list
classify l ~equal ~f
elements x
and y
of list l
are assigned to the
same class iff equal (f x) (f y)
returns true. The default for equal
is ( = )
val enumerate_from : int ‑> 'a list ‑> ('a * int) list
enumerate_from n xs
returns a list of pairs constructed by pairing an
incrementing counter, starting at n
, with the elements of xs
.
e.g. enumerate_from 1 a,b,c
= a,1; b,2; c,3
val map_accum : 'a list ‑> f:('b ‑> 'a ‑> 'b * 'c) ‑> init:'b ‑> 'b * 'c list
A combination of map
and fold
. Applies a function to each element of the input
list, building up an accumulator, returning both the final state of the accumulator
and a new list.
Numbers the elements in a list by occurence:
[a;b;c;a;d] -> [(a,0);(b,0);(c,0);(a,1);(d,0)]
val multimerge : 'a list list ‑> 'a list
Merges several list trying to keep the order in which the elements appear. The elements of the individual are not deduped.
multimerge [[a;b;d;a] [b;c;d]] -> [a;b;c;d;a]
val square : ?null:'v ‑> ('k * 'v) list list ‑> 'k list * 'v list list
Takes a list of `key*`value lists
and returns a
header * table_body body that is obtained by splitting the lists and
re-ordering the terms (so that they all have the same header).
If null_value
is not specified and the rows have different keys
the function will raise an exception.
square ~null
[[(1,a_1);(2,b_1);(4,c_1)];
[(3,a_2)];
[(0,a_3);(1,b_3);(2,c_3);(3,d_3);(4,e_3)]]
=
([0 ;1 ;2 ;3 ;4],
[[null;a_1 ;b_1 ;null;c_1 ]
[null;null;null;a_2 ;null]
[a_3 ;b_3 ;c_3 ;d_3 ;e_3 ]])