ocaml-base-compiler
-
library dynlink
-
module Dynlink
-
-
library ocamlbytecomp
-
module Bytegen
-
module Bytelibrarian
-
module Bytelink
-
module Bytepackager
-
module Compile
-
module Emitcode
-
module Errors
-
module Instruct
-
module Maindriver
-
module Printinstr
-
-
library ocamlcommon
-
module Ast_helper
-
module Attr
-
module Cf
-
module Ci
-
module Cl
-
module Const
-
module Csig
-
module Cstr
-
module Ctf
-
module Cty
-
module Exp
-
module Incl
-
module Mb
-
module Md
-
module Mod
-
module Ms
-
module Mtd
-
module Mty
-
module Of
-
module Opn
-
module Pat
-
module Rf
-
module Sig
-
module Str
-
module Te
-
module Typ
-
module Type
-
module Val
-
module Vb
-
-
module Ast_invariants
-
module Ast_iterator
-
module Ast_mapper
-
module Attr_helper
-
module Binutils
-
module Build_path_prefix_map
-
module Builtin_attributes
-
module Bytesections
-
module CamlinternalMenhirLib
-
module Convert
-
module Simplified
-
-
module EngineTypes
-
module type ENGINE
-
module type INCREMENTAL_ENGINE_START
-
module type MONOLITHIC_ENGINE
-
-
module ErrorReports
-
module General
-
module IncrementalEngine
-
module type EVERYTHING
-
module type INCREMENTAL_ENGINE
-
module type INSPECTION
-
module type SYMBOLS
-
-
module InfiniteArray
-
module InspectionTableFormat
-
module type TABLES
-
-
module LinearizedArray
-
module PackedIntArray
-
module RowDisplacement
-
module StaticVersion
-
module TableFormat
-
module type TABLES
-
-
module TableInterpreter
-
module MakeEngineTable
-
-
-
module Ccomp
-
module Clflags
-
module Compiler_pass
-
module Float_arg_helper
-
module Int_arg_helper
-
-
module Cmi_format
-
module Cmt2annot
-
module Cmt_format
-
module Compenv
-
module Compile_common
-
module Compmisc
-
module Config
-
module Ctype
-
module TypePairs
-
module Unification_trace
-
-
module Datarepr
-
module Debuginfo
-
module Scoped_location
-
-
module Depend
-
module Dll
-
module Docstrings
-
module WithMenhir
-
-
module Domainstate
-
module Env
-
module Envaux
-
module Includeclass
-
module Includecore
-
module Includemod
-
module Lambda
-
module Lexer
-
module Local_store
-
module Location
-
module Longident
-
module Main_args
-
module type Arg_list
-
module type Bytecomp_options
-
module type Bytetop_options
-
module type Common_options
-
module type Compiler_options
-
module type Core_options
-
module Make_bytecomp_options
-
argument 1-_
-
-
module Make_bytetop_options
-
argument 1-_
-
-
module Make_ocamldoc_options
-
argument 1-_
-
-
module Make_optcomp_options
-
argument 1-_
-
-
module Make_opttop_options
-
argument 1-_
-
-
module type Ocamldoc_options
-
module type Optcommon_options
-
module type Optcomp_options
-
module type Opttop_options
-
module type Toplevel_options
-
-
module Makedepend
-
module Matching
-
module Meta
-
module Misc
-
module Color
-
module EnvLazy
-
module Error_style
-
module Int_literal_converter
-
module LongString
-
module Magic_number
-
-
module Mtype
-
module Opcodes
-
module Oprint
-
module Parse
-
module Parser
-
module Incremental
-
module MenhirInterpreter
-
-
module Patterns
-
module General
-
module Half_simple
-
module Head
-
module Non_empty_row
-
module Simple
-
-
module Persistent_env
-
module Consistbl
-
module Persistent_signature
-
-
module Pparse
-
module Pprintast
-
module Predef
-
module Primitive
-
module Printast
-
module Printlambda
-
module Printpat
-
module Printtyp
-
module Conflicts
-
module Naming_context
-
module Out_name
-
-
module Printtyped
-
module Profile
-
module Rec_check
-
module Runtimedef
-
module Simplif
-
module Stypes
-
module Subst
-
module Symtable
-
module Syntaxerr
-
module Targetint
-
module Tast_iterator
-
module Tast_mapper
-
module Terminfo
-
module Translattribute
-
module Translclass
-
module Translcore
-
module Translmod
-
module Translobj
-
module Translprim
-
module Type_immediacy
-
module Violation
-
-
module Typeclass
-
module Typecore
-
module Datatype_kind
-
-
module Typedecl
-
module Typedecl_immediacy
-
module Typedecl_properties
-
module Typedecl_separability
-
module Typedecl_unboxed
-
module Typedecl_variance
-
module Typedtree
-
module Typemod
-
module Sig_component_kind
-
module Signature_names
-
-
module Typeopt
-
module Typetexp
-
module Untypeast
-
module Warnings
-
library ocamlmiddleend
-
module Alias_analysis
-
module Allocated_const
-
module Augment_specialised_args
-
module Definition
-
module type S
-
module What_to_specialise
-
-
module Backend_var
-
module Provenance
-
module With_provenance
-
-
module Build_export_info
-
module Clambda
-
module Clambda_primitives
-
module Closure
-
module Closure_conversion
-
module Closure_conversion_aux
-
module Env
-
module Function_decls
-
module Function_decl
-
-
-
module Closure_element
-
module Closure_id
-
module Closure_middle_end
-
module Closure_offsets
-
module Closure_origin
-
module Compilation_unit
-
module Compilenv
-
module Convert_primitives
-
module Effect_analysis
-
module Export_info
-
module Export_info_for_pack
-
module Extract_projections
-
module Find_recursive_functions
-
module Flambda
-
module Constant_defining_value
-
module With_free_variables
-
-
module Flambda_invariants
-
module Flambda_iterators
-
module Flambda_middle_end
-
module Flambda_to_clambda
-
module Flambda_utils
-
module Switch_storer
-
-
module Freshening
-
module Project_var
-
-
module Id_types
-
module type BaseId
-
module Id
-
module UnitId
-
argument 1-_
-
argument 2-Compilation_unit
-
module Compilation_unit
-
-
-
module Import_approx
-
module Inconstant_idents
-
module Inline_and_simplify
-
module Inline_and_simplify_aux
-
module Inlining_cost
-
module Benefit
-
module Threshold
-
module Whether_sufficient_benefit
-
-
module Inlining_decision
-
module Inlining_stats
-
module Closure_stack
-
-
module Inlining_stats_types
-
module Decision
-
module Inlined
-
module Not_inlined
-
module Not_specialised
-
module Prevented
-
module Specialised
-
-
module Inlining_transforms
-
module Internal_variable_names
-
module Invariant_params
-
module Lift_code
-
module Lift_constants
-
module Linkage_name
-
module Mutable_variable
-
module Pass_wrapper
-
module Printclambda
-
module Printclambda_primitives
-
module Projection
-
module Ref_to_variables
-
module Remove_unused_arguments
-
module Remove_unused_closure_vars
-
module Semantics_of_primitives
-
module Set_of_closures_id
-
module Set_of_closures_origin
-
module Share_constants
-
module Simple_value_approx
-
module Simplify_boxed_integer_ops
-
module Simplify_boxed_int32
-
module Simplify_boxed_int64
-
module Simplify_boxed_nativeint
-
-
module Simplify_common
-
module Simplify_primitives
-
module Static_exception
-
module Un_anf
-
module Unbox_closures
-
module Unbox_free_vars_of_closures
-
module Unbox_specialised_args
-
module Var_within_closure
-
-
library ocamloptcomp
-
module Afl_instrument
-
module Alias_analysis
-
module Allocated_const
-
module Arch
-
module Asmgen
-
module Asmlibrarian
-
module Asmlink
-
module Asmpackager
-
module Augment_specialised_args
-
module Definition
-
module type S
-
module What_to_specialise
-
-
module Available_regs
-
module Backend_var
-
module Provenance
-
module With_provenance
-
-
module Branch_relaxation
-
module Make
-
argument 1-T
-
module Cond_branch
-
-
-
-
module Branch_relaxation_intf
-
module type S
-
module Cond_branch
-
-
-
module Build_export_info
-
module CSEgen
-
module Clambda
-
module Clambda_primitives
-
module Closure
-
module Closure_conversion
-
module Closure_conversion_aux
-
module Env
-
module Function_decls
-
module Function_decl
-
-
-
module Closure_element
-
module Closure_id
-
module Closure_middle_end
-
module Closure_offsets
-
module Closure_origin
-
module Cmm
-
module Cmm_helpers
-
module Cmmgen
-
module Cmmgen_state
-
module Coloring
-
module Comballoc
-
module Compilation_unit
-
module Compilenv
-
module Compute_ranges
-
module Make
-
argument 1-S
-
module Range_info
-
module Subrange_info
-
module Subrange_state
-
module Range
-
module Subrange
-
-
-
module Compute_ranges_intf
-
module type S
-
module Range
-
module Range_info
-
module Subrange
-
module Subrange_info
-
module Subrange_state
-
module type S_functor
-
module Range_info
-
module Subrange_info
-
module Subrange_state
-
module type S_range_info
-
module type S_subrange_info
-
module type S_subrange_state
-
-
module Convert_primitives
-
module Deadcode
-
module Effect_analysis
-
module Emit
-
module Emitaux
-
module Export_info
-
module Export_info_for_pack
-
module Extract_projections
-
module Find_recursive_functions
-
module Flambda
-
module Constant_defining_value
-
module With_free_variables
-
-
module Flambda_invariants
-
module Flambda_iterators
-
module Flambda_middle_end
-
module Flambda_to_clambda
-
module Flambda_utils
-
module Switch_storer
-
-
module Freshening
-
module Project_var
-
-
module Id_types
-
module type BaseId
-
module Id
-
module UnitId
-
argument 1-_
-
argument 2-Compilation_unit
-
module Compilation_unit
-
-
-
module Import_approx
-
module Inconstant_idents
-
module Inline_and_simplify
-
module Inline_and_simplify_aux
-
module Inlining_cost
-
module Benefit
-
module Threshold
-
module Whether_sufficient_benefit
-
-
module Inlining_decision
-
module Inlining_stats
-
module Closure_stack
-
-
module Inlining_stats_types
-
module Decision
-
module Inlined
-
module Not_inlined
-
module Not_specialised
-
module Prevented
-
module Specialised
-
-
module Inlining_transforms
-
module Interf
-
module Internal_variable_names
-
module Interval
-
module Invariant_params
-
module Lift_code
-
module Lift_constants
-
module Linear
-
module Linear_format
-
module Linearize
-
module Linkage_name
-
module Linscan
-
module Liveness
-
module Mach
-
module Mutable_variable
-
module Optcompile
-
module Opterrors
-
module Optmaindriver
-
module Pass_wrapper
-
module Printclambda
-
module Printclambda_primitives
-
module Printcmm
-
module Printlinear
-
module Printmach
-
module Proc
-
module Projection
-
module Ref_to_variables
-
module Reg_availability_set
-
module Reg_with_debug_info
-
module Debug_info
-
module Set
-
-
module Reload
-
module Reloadgen
-
module Remove_unused_arguments
-
module Remove_unused_closure_vars
-
module Schedgen
-
module Scheduling
-
module Selectgen
-
module Coeffect
-
module Effect
-
module Effect_and_coeffect
-
-
module Selection
-
module Semantics_of_primitives
-
module Set_of_closures_id
-
module Set_of_closures_origin
-
module Share_constants
-
module Simple_value_approx
-
module Simplify_boxed_integer_ops
-
module Simplify_boxed_int32
-
module Simplify_boxed_int64
-
module Simplify_boxed_nativeint
-
-
module Simplify_common
-
module Simplify_primitives
-
module Spill
-
module Split
-
module Static_exception
-
module Un_anf
-
module Unbox_closures
-
module Unbox_free_vars_of_closures
-
module Unbox_specialised_args
-
module Var_within_closure
-
module X86_gas
-
module X86_masm
-
module X86_proc
-
-
library odoc_info
-
module Odoc_analyse
-
module Odoc_ast
-
module Typedtree_search
-
module Odoc_class
-
module Odoc_comments
-
module Basic_info_retriever
-
module type Texter
-
-
module Odoc_comments_global
-
module Odoc_config
-
module Odoc_control
-
module Odoc_cross
-
module Odoc_env
-
module Odoc_exception
-
module Odoc_extension
-
module Odoc_global
-
module Odoc_inherit
-
module Odoc_lexer
-
module Odoc_merge
-
module Odoc_messages
-
module Odoc_misc
-
module Odoc_module
-
module Odoc_parameter
-
module Odoc_parser
-
module Odoc_print
-
module Odoc_search
-
module P_name
-
module type Predicates
-
module Search_by_name
-
-
module Odoc_see_lexer
-
module Odoc_sig
-
module type Info_retriever
-
module Signature_search
-
module Odoc_str
-
module Odoc_text_lexer
-
module Odoc_text_parser
-
module Odoc_type
-
module Odoc_types
-
module Odoc_value
-
-
library stdlib
-
module CamlinternalAtomic
-
module CamlinternalFormat
-
module CamlinternalFormatBasics
-
module CamlinternalLazy
-
module CamlinternalMod
-
module CamlinternalOO
-
module Stdlib
-
module Arg
-
module Array
-
module ArrayLabels
-
module Atomic
-
module Bool
-
module Buffer
-
module Bytes
-
module BytesLabels
-
module Callback
-
module Char
-
module Complex
-
module Digest
-
module Either
-
module Ephemeron
-
module GenHashTable
-
module MakeSeeded
-
argument 1-H
-
-
-
module K1
-
module MakeSeeded
-
argument 1-H
-
-
module Kn
-
module MakeSeeded
-
argument 1-H
-
-
module type S
-
module type SeededS
-
-
module Filename
-
module Float
-
module Array
-
module ArrayLabels
-
-
module Format
-
module Fun
-
module Genlex
-
module Hashtbl
-
module type HashedType
-
module MakeSeeded
-
argument 1-H
-
-
module type S
-
module type SeededHashedType
-
module type SeededS
-
-
module Int
-
module Int32
-
module Int64
-
module LargeFile
-
module Lazy
-
module Lexing
-
module List
-
module ListLabels
-
module Map
-
module type OrderedType
-
module type S
-
module Marshal
-
module MoreLabels
-
module Hashtbl
-
module type HashedType
-
module MakeSeeded
-
argument 1-H
-
-
module type S
-
module type SeededHashedType
-
module type SeededS
-
-
module Map
-
module type OrderedType
-
module type S
-
module Set
-
module type OrderedType
-
module type S
-
-
module Nativeint
-
module Obj
-
module Closure
-
module Ephemeron
-
module Extension_constructor
-
-
module Oo
-
module Option
-
module Parsing
-
module Pervasives
-
module Printf
-
module Queue
-
module Result
-
module Seq
-
module Set
-
module type OrderedType
-
module type S
-
module Stack
-
module StdLabels
-
module Stream
-
module String
-
module StringLabels
-
module Sys
-
module Immediate64
-
module type Immediate
-
module Make
-
argument 1-Immediate
-
argument 2-Non_immediate
-
-
module type Non_immediate
-
-
-
module Uchar
-
module Unit
-
-
-
library str
-
module Str
-
-
library unix
-
module UnixLabels
-
module LargeFile
-
Compare the lengths of two lists. compare_lengths l1 l2
is equivalent to compare (length l1) (length l2)
, except that the computation stops after reaching the end of the shortest list.
Compare the length of a list to an integer. compare_length_with l len
is equivalent to compare (length l) len
, except that the computation stops after at most len
iterations on the list.
Return the n
-th element of the given list. The first element (head of the list) is at position 0.
Return the n
-th element of the given list. The first element (head of the list) is at position 0. Return None
if the list is too short.
init ~len ~f
is f 0; f 1; ...; f (len-1)
, evaluated left to right.
Concatenate two lists. Same function as the infix operator @
. Not tail-recursive (length of the first argument). The @
operator is not tail-recursive either.
rev_append l1 l2
reverses l1
and concatenates it with l2
. This is equivalent to (
rev
l1) @ l2
, but rev_append
is tail-recursive and more efficient.
Concatenate a list of lists. The elements of the argument are all concatenated together (in the same order) to give the result. Not tail-recursive (length of the argument + length of the longest sub-list).
Same as concat
. Not tail-recursive (length of the argument + length of the longest sub-list).
Comparison
equal eq [a1; ...; an] [b1; ..; bm]
holds when the two input lists have the same length, and for each pair of elements ai
, bi
at the same position we have eq ai bi
.
Note: the eq
function may be called even if the lists have different length. If you know your equality function is costly, you may want to check compare_lengths
first.
compare cmp [a1; ...; an] [b1; ...; bm]
performs a lexicographic comparison of the two input lists, using the same 'a -> 'a -> int
interface as Stdlib.compare
:
a1 :: l1
is smaller thana2 :: l2
(negative result) ifa1
is smaller thana2
, or if they are equal (0 result) andl1
is smaller thanl2
- the empty list
[]
is strictly smaller than non-empty lists
Note: the cmp
function will be called even if the lists have different lengths.
Iterators
iter ~f [a1; ...; an]
applies function f
in turn to a1; ...; an
. It is equivalent to begin f a1; f a2; ...; f an; () end
.
Same as iter
, but the function is applied to the index of the element as first argument (counting from 0), and the element itself as second argument.
map ~f [a1; ...; an]
applies function f
to a1, ..., an
, and builds the list [f a1; ...; f an]
with the results returned by f
. Not tail-recursive.
Same as map
, but the function is applied to the index of the element as first argument (counting from 0), and the element itself as second argument. Not tail-recursive.
filter_map ~f l
applies f
to every element of l
, filters out the None
elements and returns the list of the arguments of the Some
elements.
fold_left_map
is a combination of fold_left
and map
that threads an accumulator through calls to f
.
fold_left ~f ~init [b1; ...; bn]
is f (... (f (f init b1) b2) ...) bn
.
fold_right ~f [a1; ...; an] ~init
is f a1 (f a2 (... (f an init) ...))
. Not tail-recursive.
Iterators on two lists
iter2 ~f [a1; ...; an] [b1; ...; bn]
calls in turn f a1 b1; ...; f an bn
.
map2 ~f [a1; ...; an] [b1; ...; bn]
is [f a1 b1; ...; f an bn]
.
fold_left2 ~f ~init [a1; ...; an] [b1; ...; bn]
is f (... (f (f init a1 b1) a2 b2) ...) an bn
.
fold_right2 ~f [a1; ...; an] [b1; ...; bn] ~init
is f a1 b1 (f a2 b2 (... (f an bn init) ...))
.
List scanning
for_all ~f [a1; ...; an]
checks if all elements of the list satisfy the predicate f
. That is, it returns (f a1) && (f a2) && ... && (f an)
for a non-empty list and true
if the list is empty.
exists ~f [a1; ...; an]
checks if at least one element of the list satisfies the predicate f
. That is, it returns (f a1) || (f a2) || ... || (f an)
for a non-empty list and false
if the list is empty.
Same as for_all
, but for a two-argument predicate.
Same as exists
, but for a two-argument predicate.
mem a ~set
is true if and only if a
is equal to an element of set
.
Same as mem
, but uses physical equality instead of structural equality to compare list elements.
List searching
find ~f l
returns the first element of the list l
that satisfies the predicate f
.
find ~f l
returns the first element of the list l
that satisfies the predicate f
. Returns None
if there is no value that satisfies f
in the list l
.
find_map ~f l
applies f
to the elements of l
in order, and returns the first result of the form Some v
, or None
if none exist.
filter ~f l
returns all the elements of the list l
that satisfy the predicate f
. The order of the elements in the input list is preserved.
find_all
is another name for filter
.
Same as filter
, but the predicate is applied to the index of the element as first argument (counting from 0), and the element itself as second argument.
partition ~f l
returns a pair of lists (l1, l2)
, where l1
is the list of all the elements of l
that satisfy the predicate f
, and l2
is the list of all the elements of l
that do not satisfy f
. The order of the elements in the input list is preserved.
val partition_map :
f:( 'a -> ( 'b, 'c ) Either.t ) ->
'a list ->
'b list * 'c list
partition_map f l
returns a pair of lists (l1, l2)
such that, for each element x
of the input list l
:
- if
f x
isLeft y1
, theny1
is inl1
, and - if
f x
isRight y2
, theny2
is inl2
.
The output elements are included in l1
and l2
in the same relative order as the corresponding input elements in l
.
In particular, partition_map (fun x -> if f x then Left x else Right x) l
is equivalent to partition f l
.
Association lists
assoc a l
returns the value associated with key a
in the list of pairs l
. That is, assoc a [ ...; (a,b); ...] = b
if (a,b)
is the leftmost binding of a
in list l
.
assoc_opt a l
returns the value associated with key a
in the list of pairs l
. That is, assoc_opt a [ ...; (a,b); ...] = Some b
if (a,b)
is the leftmost binding of a
in list l
. Returns None
if there is no value associated with a
in the list l
.
Same as assoc
, but uses physical equality instead of structural equality to compare keys.
Same as assoc_opt
, but uses physical equality instead of structural equality to compare keys.
Same as assoc
, but simply return true
if a binding exists, and false
if no bindings exist for the given key.
Same as mem_assoc
, but uses physical equality instead of structural equality to compare keys.
remove_assoc a l
returns the list of pairs l
without the first pair with key a
, if any. Not tail-recursive.
Same as remove_assoc
, but uses physical equality instead of structural equality to compare keys. Not tail-recursive.
Lists of pairs
Transform a list of pairs into a pair of lists: split [(a1,b1); ...; (an,bn)]
is ([a1; ...; an], [b1; ...; bn])
. Not tail-recursive.
Transform a pair of lists into a list of pairs: combine [a1; ...; an] [b1; ...; bn]
is [(a1,b1); ...; (an,bn)]
.
Sorting
Sort a list in increasing order according to a comparison function. The comparison function must return 0 if its arguments compare as equal, a positive integer if the first is greater, and a negative integer if the first is smaller (see Array.sort for a complete specification). For example, Stdlib.compare
is a suitable comparison function. The resulting list is sorted in increasing order. sort
is guaranteed to run in constant heap space (in addition to the size of the result list) and logarithmic stack space.
The current implementation uses Merge Sort. It runs in constant heap space and logarithmic stack space.
Same as sort
, but the sorting algorithm is guaranteed to be stable (i.e. elements that compare equal are kept in their original order).
The current implementation uses Merge Sort. It runs in constant heap space and logarithmic stack space.
Same as sort
or stable_sort
, whichever is faster on typical input.
Same as sort
, but also remove duplicates.
Merge two lists: Assuming that l1
and l2
are sorted according to the comparison function cmp
, merge ~cmp l1 l2
will return a sorted list containing all the elements of l1
and l2
. If several elements compare equal, the elements of l1
will be before the elements of l2
. Not tail-recursive (sum of the lengths of the arguments).
Iterators
val to_seq : 'a list -> 'a Seq.t
Iterate on the list.
val of_seq : 'a Seq.t -> 'a list
Create a list from the iterator.