, 1 Kind tests ? Is_long(v) is true if value v is an immediate integer, false otherwise ? Is_block(v) is true if value v is a pointer to a block, and false if it is an immediate integer

, on integers ? Val_long(l) returns the value encoding the long int l

, ? Long_val(v) returns the long int encoded in value v

, ? Val_int(i) returns the value encoding the int i

, ? Int_val(v) returns the int encoded in value v

, ? Val_bool(x) returns the OCaml boolean representing the truth value of the C integer x

, ? Bool_val(v) returns 0 if v is the OCaml boolean false, 1 if v is true

, ? Val_true, Val_false represent the OCaml booleans true and false

, Accessing blocks ? Wosize_val(v) returns the size of the block v, in words, excluding the header

, ? Tag_val(v) returns the tag of the block v

, ? Field(v, n) returns the value contained in the n th field of the structured block v. Fields are numbered from 0 to Wosize_val

, ? Store_field(b, n, v) stores the value v in the field number n of value b, which must be a structured block

, ? Code_val(v) returns the code part of the closure v

, ? caml_string_length(v) returns the length (number of bytes) of the string or byte sequence v

, ? Byte(v, n) returns the n th byte of the string or byte sequence v, with type char. Bytes are numbered from 0 to string_length

, v, n) returns the n th byte of the string or byte sequence v, with type unsigned char. Bytes are numbered from 0 to string_length

, ? String_val(v) returns a pointer to the first byte of the string v, with type char * or, when OCaml is configured with -force-safe-string, with type const char *. This pointer is a valid C string: there is a null byte after the last byte in the string. However, OCaml strings can contain embedded null bytes

, Same as Array.map[26.2], but the function is applied to the index of the element as first argument, and the element itself as second argument

V. Fold_left,

V. Fold_right, ) ( ... (f a.(n-1) x) ...)), where n is the length of the array a

, b -> unit) -> 'a array -> 'b array -> unit Array.iter2 f a b applies function f to all the elements of a and b. Raise Invalid_argument if the arrays are not the same size, Iterators on two arrays val iter2

. Val-map2, c array Array.map2 f a b applies function f to all the elements of a and b, and builds an array with the results returned by f: [| f a.(0) b.(0); ...; f a.(Array.length a -1) b.(Array.length b -1)|], Raise Invalid_argument if the arrays are not the same size. Since: 4.03

. Array, > 'a array -> bool Array.for_all p [|a1; ...; an|] checks if all elements of the array satisfy the predicate p. That is, it returns, a1) && (p a2) && ... && (p an)

, Since: 4.03

. Val, > 'a array -> bool Array.exists p [|a1; ...; an|] checks if at least one element of the array satisfies the predicate p. That is, it returns, a1) || (p a2) || ... || (p an)

, Since: 4.03

V. Mem, array -> bool mem a l is true if and only if a is equal to an element of l

V. Memq, array -> bool Same as Array.mem[26.2], but uses physical equality instead of structural equality to compare array elements

, Since: 4.03

V. Of_list, a list -> 'a array Array.of_list l returns a fresh array containing the elements of l

V. Iter, > 'a array -> unit Array.iter f a applies function f in turn to all the elements of a. It is equivalent to f a

, > 'a array -> 'b array Array.map f a applies function f to all the elements of a, and builds an array with the results returned by f: [| f a

V. Iteri, f:(int -> 'a -> unit) -> 'a array -> unit Same as Array.iter[26.2], but the function is applied to the index of the element as first argument, and the element itself as second argument

V. Mapi, f:(int -> 'a -> 'b) -> 'a array -> 'b array Same as Array.map[26.2], but the function is applied to the index of the element as first argument, and the element itself as second argument

V. Fold_left, > init:'a -> 'b array -> 'a Array

V. Fold_right, > 'b array -> init:'a -> 'a Array, ) ( ... (f a.(n-1) x) ...)), where n is the length of the array a

, b -> unit) -> 'a array -> 'b array -> unit Array.iter2 f a b applies function f to all the elements of a and b. Raise Invalid_argument if the arrays are not the same size

. Val-map2, c array Array.map2 f a b applies function f to all the elements of a and b, and builds an array with the results returned by f: [| f a.(0) b.(0); ...; f a.(Array.length a -1) b.(Array.length b -1)|], Raise Invalid_argument if the arrays are not the same size. Since: 4.05

, Array scanning val exists : f:('a -> bool) -> 'a array -> bool Array.exists p [|a1; ...; an|] checks if at least one element of the array satisfies the predicate p. That is, it returns, a1) || (p a2) || ... || (p an)

, Since: 4.03

, the type of the array elements proper: for instance, a big array whose elements are of kind float32_elt contains 32-bit single precision floats, but reading or writing one of its elements from OCaml uses the OCaml type float, which is 64-bit double precision floats

G. The, b) kind captures this association of an OCaml type 'a for values read or written in the big array, and of an element kind 'b which represents the actual contents of the big array. Its constructors list all possible associations of OCaml types with element kinds, and are re-exported below for backward-compatibility reasons

, GADT) here allows to write well-typed polymorphic functions whose return type depend on the argument type, such as: let zero : type a b. (a, b) kind -> a = function | Float32 -> 0.0 | Complex32 -> Complex

, Int32 -> 0l | Int64 -> 0L | Int -> 0 | Nativeint -> 0n | Char -> '\000' val float32 : (float, float32_elt)

, val float64 : (float, float64_elt) kind See Bigarray.char[26

, val complex32 : (Complex.t, complex32_elt) kind See Bigarray.char[26

, val complex64 : (Complex.t, complex64_elt) kind See Bigarray.char[26

, val int8_signed : (int, int8_signed_elt) kind See Bigarray.char[26

, val int8_unsigned : (int, int8_unsigned_elt) kind See Bigarray.char[26

, val int16_signed : (int, int16_signed_elt) kind See Bigarray.char[26

, val int16_unsigned : (int, int16_unsigned_elt) kind See Bigarray.char[26

, val int : (int, int_elt) kind See Bigarray.char[26

, val int32 : (int32, int32_elt) kind See Bigarray.char[26

, val int64 : (int64, int64_elt) kind See Bigarray.char[26

, val nativeint : (nativeint, nativeint_elt) kind See Bigarray.char[26

A. , sharing the data with a (and hence having the same dimensions as a) No copying of elements is involved: the new array and the original array share the same storage space. The dimensions are reversed, such that get v [| a; b; c |] in C layout becomes get v [| c+1; b+1

. Val-size_in_bytes, c) t -> int size_in_bytes a is the number of elements in a multiplied by a's Bigarray

. Val,

A. , {x,y,z}, returns the element of a at coordinates (x, y, z). x, y and z must be within the bounds of a, as described for Bigarray

. Val, c) t -> int -> int -> int -> 'a -> unit Array3.set a x y v, or alternatively a.{x,y,z} <-v, stores the value v at coordinates (x, y, z) in a. x, y and z must be within the bounds of a

V. Sub_left, Bigarray.c_layout) t -> int -> int -> ('a

, Extract a three-dimensional sub-array of the given three-dimensional big array by restricting the first dimension

V. Sub_right, Bigarray.fortran_layout) t -> int -> int -> ('a

, Extract a three-dimensional sub-array of the given three-dimensional big array by restricting the second dimension

. Val-slice_left_1, Bigarray.c_layout) t -> int -> int -> ('a, 'b, Bigarray.c_layout) Bigarray.Array1.t Extract a one-dimensional slice of the given three-dimensional big array by fixing the first two coordinates. The integer parameters are the coordinates of the slice to extract

A. , slice_left_1 applies only to arrays with C layout. end Three-dimensional arrays. The Array3 structure provides operations similar to those of Bigarray.Genarray[26

, Coercions between generic big arrays and fixed-dimension big arrays val genarray_of_array0 : ('a, 'b, 'c) Array0.t -> ('a, 'b, 'c) Genarray.t Return the generic big array corresponding to the given zero-dimensional big array

. Val-genarray_of_array1, c) Array1.t -> ('a, 'b, 'c) Genarray.t Return the generic big array corresponding to the given one-dimensional big array

. Val-genarray_of_array2, c) Array2.t -> ('a, 'b, 'c) Genarray.t Return the generic big array corresponding to the given two-dimensional big array

. Val-genarray_of_array3, c) Array3.t -> ('a, 'b, 'c) Genarray.t Return the generic big array corresponding to the given three-dimensional big array

, c) Genarray.t -> ('a, 'b, 'c) Array0.t Return the zero-dimensional big array corresponding to the given generic big array. Raise Invalid_argument if the generic big array does not have exactly zero dimension

, c) Genarray.t -> ('a, 'b, 'c) Array1.t Return the one-dimensional big array corresponding to the given generic big array, Raise Invalid_argument if the generic big array does not have exactly one dimension

, c) Genarray.t -> ('a, 'b, 'c) Array2.t Return the two-dimensional big array corresponding to the given generic big array, Raise Invalid_argument if the generic big array does not have exactly two dimensions

, c) Genarray.t -> ('a, 'b, 'c) Array3.t Return the three-dimensional big array corresponding to the given generic big array, Raise Invalid_argument if the generic big array does not have exactly three dimensions

, c) Genarray.t -> int array -> ('a, 'b, 'c) Genarray.t an ephemeron with two keys val create : unit -> ('k1, 'k2, Re-shaping big arrays val reshape

, val get_key1 : ('k1, 'k2, 'd) t -> 'k1 option Same as Ephemeron

, val get_key1_copy : ('k1, 'k2, 'd) t -> 'k1 option Same as Ephemeron

, val set_key1 : ('k1, 'k2, 'd) t -> 'k1 -> unit Same as Ephemeron

. Val-unset_key1, ('k1, 'k2, 'd) t -> unit Same as Ephemeron

. Val-check_key1, ('k1, 'k2, 'd) t -> bool Same as Ephemeron

, val get_key2 : ('k1, 'k2, 'd) t -> 'k2 option Same as Ephemeron

, val get_key2_copy : ('k1, 'k2, 'd) t -> 'k2 option Same as Ephemeron

, val set_key2 : ('k1, 'k2, 'd) t -> 'k2 -> unit Same as Ephemeron

. Val-unset_key2, ('k1, 'k2, 'd) t -> unit Same as Ephemeron

. Val-check_key2, ('k1, 'k2, 'd) t -> bool Same as Ephemeron

. Val-blit_key1, b) t -> ('k1, 'c, 'd) t -> unit Same as Ephemeron

. Val-blit_key2, k2, 'b) t -> ('c, 'k2, 'd) t -> unit Same as Ephemeron

, val get_key : ('k, 'd) t -> int -> 'k option Same as Ephemeron

, val get_key_copy : ('k, 'd) t -> int -> 'k option Same as Ephemeron

, val set_key : ('k, 'd) t -> int -> 'k -> unit Same as Ephemeron

V. Unset_key, ('k, 'd) t -> int -> unit Same as Ephemeron

V. Check_key, ('k, 'd) t -> int -> bool Same as Ephemeron

V. Blit_key, a) t -> int -> ('k, 'b) t -> int -> int -> unit Same as Ephemeron

, val get_data : ('k, 'd) t -> 'd option Same as Ephemeron

, val get_data_copy : ('k, 'd) t -> 'd option Same as Ephemeron

, val set_data : ('k, 'd) t -> 'd -> unit Same as Ephemeron

V. Unset_data, ('k, 'd) t -> unit Same as Ephemeron

V. Check_data, ('k, 'd) t -> bool Same as Ephemeron

V. Blit_data, d) t -> unit Same as Ephemeron.K1.blit_data[26.12] module Make : functor (H : Hashtbl.HashedType) -> Ephemeron.S with type key = H.t array Integer remainder. If y is not zero, the result of Int32.rem x y satisfies the following property: x = Int32, add (Int32.mul (Int32.div x y) y) (Int32.rem x y). If y = 0, Int32.rem x y raises Division_by_zero

, val succ : int32 -> int32 Successor. Int32.succ x is Int32

, val pred : int32 -> int32 Predecessor. Int32.pred x is Int32

, val abs : int32 -> int32 Return the absolute value of its argument

, val max_int : int32 The greatest representable 32-bit integer, pp.31-32

, val min_int : int32 The smallest representable 32-bit integer, p.31

, val logand : int32 -> int32 -> int32 Bitwise logical and

, val logor : int32 -> int32 -> int32 Bitwise logical or

, val logxor : int32 -> int32 -> int32 Bitwise logical exclusive or

, val lognot : int32 -> int32 Bitwise logical negation

, val shift_left : int32 -> int -> int32

I. , shift_left x y shifts x to the left by y bits. The result is unspecified if y < 0 or y >= 32

, val shift_right : int32 -> int -> int32

I. , shift_right x y shifts x to the right by y bits. This is an arithmetic shift: the sign bit of x is replicated and inserted in the vacated bits. The result is

, val shift_right_logical : int32 -> int -> int32

I. , shift_right_logical x y shifts x to the right by y bits This is a logical shift: zeroes are inserted in the vacated bits regardless of the sign of x. The result is

, Integer division Raise Division_by_zero if the second argument is zero. This division rounds the real quotient of its arguments towards zero, as specified for Pervasives

V. Rem, int64 Integer remainder If y is not zero, the result of Int64.rem x y satisfies the following property: x = Int64.add (Int64.mul (Int64.div x y) y) (Int64.rem x y), pp.64-64

, val succ : int64 -> int64 Successor. Int64.succ x is Int64

, val pred : int64 -> int64 Predecessor. Int64.pred x is Int64

, val abs : int64 -> int64 Return the absolute value of its argument

, val max_int : int64 The greatest representable 64-bit integer, pp.63-64

, val min_int : int64 The smallest representable 64-bit integer, p.63

. Val,

. Val-logor,

, val logxor : int64 -> int64 -> int64 Bitwise logical exclusive or

, val lognot : int64 -> int64 Bitwise logical negation

, val shift_left : int64 -> int -> int64

I. , shift_left x y shifts x to the left by y bits. The result is unspecified if y < 0 or y >=

, val shift_right : int64 -> int -> int64

I. , shift_right x y shifts x to the right by y bits. This is an arithmetic shift: the sign bit of x is replicated and inserted in the vacated bits. The result is

V. Hd, Return the first element of the given list. Raise Failure "hd" if the list is empty

, val tl : 'a list -> 'a list Return the given list without its first element. Raise Failure "tl" if the list is empty

V. Nth, Return the n-th element of the given list. The first element (head of the list) is at position 0. Raise Failure "nth" if the list is too short

V. Nth_opt, a option 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. Raise Invalid_argument "List.nth" if n is negative, pp.4-05

. Val-rev,

V. Init, (int -> 'a) -> 'a list List.init len f is f 0; f 1; ...; f (len-1), evaluated left to right

, Raises Invalid_argument

, a list -> 'a list -> 'a list Concatenate two lists. Same as the infix operator @. Not tail-recursive (length of the first argument

. Val-rev_append, rev_append l1 l2 reverses l1 and concatenates it to l2. This is equivalent to List.rev[26.23] l1 @ l2, but rev_append is tail-recursive and more efficient

V. Concat, 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)

, val flatten : 'a list list -> 'a list An alias for concat

. Iterators-val-iter, > 'a list -> unit List.iter f [a1; ...; an] applies function f in turn to a1; ...; an. It is equivalent to begin f a1; f a2

V. Iteri, > 'a list -> unit Same as List.iter[26.23], but the function is applied to the index of the element as first argument (counting from 0), and the element itself as second argument

. Val-map, > 'a list -> 'b list List.map f [a1; ...; an] applies function f to a1, ..., an, and builds the list [f a1

V. Mapi, > 'a list -> 'b list Same as List.map[26.23], but the function is applied to the index of the element as first argument (counting from 0), and the element itself as second argument

, Since: 4.00

V. Rev_map, > 'a list -> 'b list List.rev_map f l gives the same result as List.rev[26.23] (List.map[26.23] f l), but is tail-recursive and more efficient

V. Fold_left, List.fold_left f a [b1; ...; bn] is f (... (f (f a b1) b2) ...) bn

V. Fold_right, Not tail-recursive

, > 'a list -> 'b list -> unit List.iter2 f [a1; ...; an] [b1; ...; bn] calls in turn f a1 b1, Iterators on two lists val iter2

. Val-map2, > 'a list -> 'b list -> 'c list List.map2 f [a1; ...; an] [b1; ...; bn] is [f a1 b1

. Val-rev_map2, List.rev_map2 f l1 l2 gives the same result as List.rev[26.23] (List.map2[26.23] f l1 l2), but is tail-recursive and more efficient

. Val-fold_left2, (f (f a b1 c1) b2 c2) ...) bn cn. Raise Invalid_argument if the two lists are determined to have different lengths

. Val-fold_right2, > 'a list -> 'b list -> 'c -> 'c List.fold_right2 f [a1; ...; an] [b1, pp.1-1

, > 'a list -> bool for_all p [a1; ...; an] checks if all elements of the list satisfy the predicate p. That is, it returns, List scanning val for_all a1) && (p a2) && ... && (p an)

. Val, > 'a list -> bool exists p [a1; ...; an] checks if at least one element of the list satisfies the predicate p. That is, it returns, a1) || (p a2) || ... || (p an)

. Val-for_all2, b -> bool) -> 'a list -> 'b list -> bool Same as List.for_all[26.23], but for a two-argument predicate

. Val-exists2, b -> bool) -> 'a list -> 'b list -> bool Same as List.exists[26.23], but for a two-argument predicate

V. Mem, list -> bool mem a l is true if and only if a is equal to an element of l

V. Memq, list -> bool Same as List.mem[26.23], but uses physical equality instead of structural equality to compare list elements

, > 'a list -> 'a find p l returns the first element of the list l that satisfies the predicate p. Raise Not_found if there is no value that satisfies p in the list l, List searching val find

, val flatten : 'a list list -> 'a list Same as concat. Not tail-recursive (length of the argument + length of the longest sub-list)

. Iterators-val-iter, > 'a list -> unit List.iter f [a1; ...; an] applies function f in turn to a1; ...; an. It is equivalent to begin f a1; f a2

V. Iteri, > 'a list -> unit Same as List.iter[26.23], but the function is applied to the index of the element as first argument (counting from 0), and the element itself as second argument

, > 'a list -> 'b list List.map f [a1; ...; an] applies function f to a1, ..., an, and builds the list [f a1

V. Mapi, > 'a list -> 'b list Same as List.map[26.23], but the function is applied to the index of the element as first argument (counting from 0), and the element itself as second argument

V. Rev_map, > 'a list -> 'b list List.rev_map f l gives the same result as List.rev[26.23] (List.map[26.23] f l), but is tail-recursive and more efficient

V. Fold_left, > init:'a -> 'b list -> 'a List.fold_left f a [b1, bn] is f (... (f (f a b1) b2) ...) bn

V. Fold_right, > 'a list -> init:'b -> 'b List.fold_right f [a1; ...; an] b is f a1 (f a2 (... (f an b) Not tail-recursive

, b -> unit) -> 'a list -> 'b list -> unit List.iter2 f [a1; ...; an] [b1; ...; bn] calls in turn f a1 b1

. Val-map2, > 'a list -> 'b list -> 'c list List.map2 f [a1; ...; an] [b1; ...; bn] is [f a1 b1

. Val-rev_map2, List.rev_map2 f l1 l2 gives the same result as List.rev[26.23] (List.map2[26.23] f l1 l2), but is tail-recursive and more efficient

. Val-fold_left2, > init:'a -> 'b list -> 'c list -> 'a List, (f (f a b1 c1) b2 c2) ...) bn cn. Raise Invalid_argument if the two lists are determined to have different lengths

. Val-fold_right2, > 'a list -> 'b list -> init:'c -> 'c List.fold_right2 f [a1; ...; an] [b1, pp.1-1

, > 'a list -> bool for_all p [a1; ...; an] checks if all elements of the list satisfy the predicate p. That is, it returns, List scanning val for_all a1) && (p a2) && ... && (p an)

, > 'a list -> bool exists p [a1; ...; an] checks if at least one element of the list satisfies the predicate p. That is, it returns, a1) || (p a2) || ... || (p an)

. Val-for_all2, b -> bool) -> 'a list -> 'b list -> bool Same as List.for_all[26.23], but for a two-argument predicate

. Val-exists2, b -> bool) -> 'a list -> 'b list -> bool Same as List.exists[26.23], but for a two-argument predicate

V. Mem, a -> set:'a list -> bool mem a l is true if and only if a is equal to an element of l

V. Memq, c t val union : f:(key -> 'a -> 'a -> 'a option) -> 'a t -> 'a t -> 'a t val compare : cmp:('a -> 'a -> int) -> 'a t -> 'a t -> int val equal : cmp:('a -> 'a -> bool) -> 'a t -> 'a t -> bool val iter : f:(key:key -> data:'a -> unit) -> 'a t -> unit val fold : f:(key:key -> data:'a -> 'b -> 'b) -> 'a t -> init:'b -> 'b val for_all : f:(key -> 'a -> bool) -> 'a t -> bool val exists : f:(key -> 'a -> bool) -> 'a t -> bool val filter : f:(key -> 'a -> bool) -> 'a t -> 'a t val partition : f:(key -> 'a -> bool) -> 'a t -> 'a t * 'a t val cardinal : 'a t -> int val bindings : 'a t -> (key * 'a) list val min_binding, bool Same as List.mem[26 find_first : f:(key -> bool) -> Integer remainder. If y is not zero, the result of Nativeint.rem x y satisfies the following properties: Nativeint.zero <= Nativeint.rem x y < Nativeint.abs y and x = Nativeint.add (Nativeint.mul (Nativeint.div x y) y) (Nativeint.rem x y). If y = 0, Nativeint.rem x y raises Division_by_zero

, val succ : nativeint -> nativeint Successor. Nativeint.succ x is Nativeint

, val pred : nativeint -> nativeint Predecessor. Nativeint.pred x is Nativeint

, val abs : nativeint -> nativeint Return the absolute value of its argument

, val size : int The size in bits of a native integer This is equal to 32 on a 32-bit platform and to 64 on a 64-bit platform

, val max_int : nativeint The greatest representable native integer, either 2 31 -1 on a 32-bit platform, pp.63-64

, val min_int : nativeint The smallest representable native integer, either -2 31 on a 32-bit platform, or -2 63 on a 64-bit platform

, val logand : nativeint -> nativeint -> nativeint Bitwise logical and

, val logor : nativeint -> nativeint -> nativeint Bitwise logical or

, val logxor : nativeint -> nativeint -> nativeint Bitwise logical exclusive or

, val lognot : nativeint -> nativeint Bitwise logical negation

, val shift_left : nativeint -> int -> nativeint Nativeint.shift_left x y shifts x to the left by y bits. The result is unspecified if y < 0 or y >= bitsize, where bitsize is 32 on a 32

, val shift_right : nativeint -> int -> nativeint An alias for Scanf, Scanning.open_in

, val from_file_bin : string -> in_channel An alias for Scanf, Scanning.open_in_bin

, from_string s returns a Scanf.Scanning.in_channel[26.35] formatted input channel which reads from the given string. Reading starts from the first character in the string. The end-of-input condition is set when the end of the string is reached, val from_string : string -> in_channel Scanning

. Val-from_function, > in_channel Scanning.from_function f returns a Scanf.Scanning.in_channel[26.35] formatted input channel with the given function as its reading method. When scanning needs one more character, the given function is called. When the function has no more character to provide, it must signal an end-of-input condition by raising the exception End_of_file

, val from_channel : Pervasives.in_channel -> in_channel Scanning.from_channel ic returns a Scanf.Scanning.in_channel[26.35] formatted input channel which reads from the regular Pervasives.in_channel[25.2] input channel ic argument. Reading starts at current reading position of ic

, val end_of_input : in_channel -> bool Scanning.end_of_input ic tests the end-of-input condition of the given Scanf

, val beginning_of_input : in_channel -> bool Scanning.beginning_of_input ic tests the beginning of input condition of the given Scanf

V. Name_of_input, in_channel -> string Scanning.name_of_input ic returns the name of the character source for the given Scanf

, val stdib : in_channel A deprecated alias for Scanf.Scanning.stdin[26.35], the scanning buffer reading from Pervasives

, end val set : bytes -> int -> char -> unit Deprecated This is a deprecated alias of Bytes.set[26.6]. String.set s n c modifies byte sequence s in place, replacing the byte at index n with c. You can also write s.[n] <c instead of String

, Raise Invalid_argument if n is not a valid index in s. val create : int -> bytes Deprecated. This is a deprecated alias of Bytes.create[26.6]. String.create n returns a fresh byte sequence of length n. The sequence is uninitialized and contains arbitrary bytes

, Raise Invalid_argument if n < 0 or n > Sys.max_string_length[26

, val make : int -> char -> string String.make n c returns a fresh string of length n

, Raise Invalid_argument if n < 0 or n > Sys.max_string_length[26

V. Init, (int -> char) -> string String.init n f returns a string of length n, with character i initialized to the result of f i

, Raise Invalid_argument if n < 0 or n > Sys.max_string_length[26

, Since: 4.02

, val copy : string -> string Deprecated Because strings are immutable, it doesn't make much sense to make identical copies of them

, val sub : string -> int -> int -> string String.sub s start len returns a fresh string of length len, containing the substring of s that starts at position start and has length len

, Raise Invalid_argument if start and len do not designate a valid substring of s

, val fill : bytes -> int -> int -> char -> unit Deprecated This is a deprecated alias of Bytes.fill[26.6]. String.fill s start len c modifies byte sequence s in place

, Raise Invalid_argument if start and len do not designate a valid range of s

V. Blit, string -> int -> bytes -> int -> int -> unit Same as Bytes

, val concat : string -> string list -> string String.concat sep sl concatenates the list of strings sl, inserting the separator string sep between each

. String, sub s start len returns a fresh string of length len, containing the substring of s that starts at position start and has length len

, Raise Invalid_argument if start and len do not designate a valid substring of s

, val fill : bytes -> pos:int -> len:int -> char -> unit Deprecated. This is a deprecated alias of BytesLabels.fill[26.7].String.fill s start len c modifies byte sequence s in place

, Raise Invalid_argument if start and len do not designate a valid substring of s

V. Blit, src:string -> src_pos:int -> dst:bytes -> dst_pos:int -> len:int -> unit String.blit src srcoff dst dstoff len copies len bytes from the string src, starting at index srcoff, to byte sequence dst

, Raise Invalid_argument if srcoff and len do not designate a valid range of src, or if dstoff and len do not designate a valid range of dst

V. Concat, sep:string -> string list -> string String.concat sep sl concatenates the list of strings sl, inserting the separator string sep between each

V. Iter, f:(char -> unit) -> string -> unit String.iter f s applies function f in turn to all the characters of s. It is equivalent to f s.[0]; f s.[1]; ...; f s.[String

V. Iteri, f:(int -> char -> unit) -> string -> unit Same as String.iter[26.43], but the function is applied to the index of the element as first argument (counting from 0), and the character itself as second argument

. Val-map, f:(char -> char) -> string -> string String.map f s applies function f in turn to all the characters of s and stores the results in a new string that is returned

V. Mapi, f:(int -> char -> char) -> string -> string String.mapi f s calls f with each character of s and its index (in increasing index order) and stores the results in a new string that is returned

, val trim : string -> string Return a copy of the argument, without leading and trailing whitespace. The characters regarded as whitespace are: ' ', '\012', '\n', '\r', and '\t'. If there is no leading nor trailing whitespace character in the argument, return the original string itself, not a copy

, Cygwin" (for MS-Windows, OCaml compiled with Cygwin)

=. Type-backend_type, |. Native, and . Bytecode, Other of string Currently, the official distribution only supports Native and Bytecode, but it can be other backends with alternative compilers, for example

, val backend_type : backend_type Backend type currently executing the OCaml program

, val unix : bool True if Sys.os_type = "Unix

, Since: 4.01

, val win32 : bool True if Sys.os_type = "Win32

, val cygwin : bool True if Sys.os_type = "Cygwin

, val word_size : int Size of one word on the machine currently executing the OCaml program, in bits, pp.32-64

, It is 31 (resp. 63) when using OCaml on a 32-bit (resp. 64-bit) platform. It may differ for other implementations, e.g. it can be 32 bits when compiling to JavaScript, val int_size : int Size of int

, val big_endian : bool Whether the machine currently executing the Caml program is big-endian

, Since: 4.00

, val max_string_length : int Maximum length of strings and byte sequences

, val max_array_length : int val in_file : string -> t Return an empty ghost range located in a given file

, val init : Lexing.lexbuf -> string -> unit Set the file name and line number of the lexbuf to be the start of the named file

, val curr : Lexing.lexbuf -> t Get the location of the current token from the lexbuf

, val symbol_rloc : unit -> t val symbol_gloc : unit -> t val rhs_loc : int -> t rhs_loc n returns the location of the symbol at position n, starting at 1, in the current parser rule

, ref val get_pos_info : Lexing.position -> string * int * int val print_loc : Format.formatter -> t -> unit val print_error_prefix : Format.formatter -> unit val print_error : Format.formatter -> t -> unit val print_error_cur_file : Format.formatter -> unit -> unit val print_warning : t -> Format.formatter -> Warnings.t -> unit val formatter_for_warnings : Format.formatter Pervasives.ref val prerr_warning : t -> Warnings.t -> unit val echo_eof : unit -> unit val reset : unit -> unit val default_printer : Format.formatter -> t -> unit val printer : (Format.formatter -> t -> unit) Pervasives, val input_name : string Pervasives.ref val input_lexbuf : Lexing.lexbuf option Pervasivesref val warning_printer : (t -> Format.formatter -> Warnings.t -> unit) Pervasives.ref Hook for intercepting warnings

, val default_warning_printer : t -> Format.formatter -> Warnings.t -> unit Original warning printer for use in hooks

, formatter -> Lexing.lexbuf -> t -> unit type 'a loc = { txt : 'a ; loc : t ; Each compiler module which defines a custom type of exception which can surface as a user-visible error should register a " printer " for this exception using register_error_of_exn. The result of the printer is an error value containing a location, a message, and optionally sub-messages (each of them being located as well)

, val report_error : Format.formatter -> error -> unit val error_reporter : (Format.formatter -> error -> unit) Pervasives.ref Hook for intercepting error reports

, val default_error_reporter : Format.formatter -> error -> unit Original error reporter for use in hooks

, val report_exception : Format.formatter -> exn -> unit Reraise the exception if it is unknown

, val deprecated : ?def:t -> ?use:t -> t -> string -> unit

, Module Longident : Long identifiers, used in parsetree. type t = | Lident of string | Ldot of t * string | Lapply of t * t val flatten : t -> string list val unflatten : string list -> t option val last : t -> string val parse : string -> t

, Module Parse : Entry points in the parser val implementation : Lexing.lexbuf -> Parsetree.structure val interface : Lexing.lexbuf -> Parsetree.signature val toplevel_phrase : Lexing.lexbuf -> Parsetree.toplevel_phrase val use_file : Lexing.lexbuf -> Parsetree.toplevel_phrase list val core_type : Lexing.lexbuf -> Parsetree.core_type val expression : Lexing.lexbuf -> Parsetree.expression val pattern : Lexing.lexbuf -> Parsetree.pattern Fork a new process. The returned integer is 0 for the child process, the pid of the child process for the parent process

, On Windows: not implemented

V. Wait, unit -> int * process_status Wait until one of the children processes die, and return its pid and termination status. On Windows: Not implemented

V. Waitpid, int -> int * process_status Same as Unix.wait[28.1], but waits for the child process whose pid is given. A pid of -1 means wait for any child. A pid of 0 means wait for any child in the same process group as the current process. Negative pid arguments represent process groups, The list of options indicates whether waitpid should return immediately without waiting, and whether it should report stopped children

, On Windows, this function can only wait for a given PID, not any child process

, val system : string -> process_status Execute the given command, wait until it terminates, and return its termination status. The string is interpreted by the shell /bin/sh (or the command interpreter cmd.exe on Windows) and therefore can contain redirections, quotes, variables, etc. The result WEXITED 127 indicates that the shell couldn

, val getpid : unit -> int Return the pid of the process

, val getppid : unit -> int Return the pid of the parent process. On Windows: not implemented (because it is meaningless)

, val nice : int -> int Change the process priority. The integer argument is added to the " nice " value. (Higher values of the " nice " value mean lower priorities.) Return the new nice value

, On Windows: not implemented

, Basic file input/output type file_descr The abstract type of file descriptors

, val stdin : file_descr File descriptor for standard input

, val stdout : file_descr create_process_env prog args env new_stdin new_stdout new_stderr works as Unix.create_process[28.1], except that the extra argument env specifies the environment passed to the program

, in_channel High-level pipe and process management This function runs the given command in parallel with the program. The standard output of the command is redirected to a pipe, which can be read via the returned input channel. The command is interpreted by the shell /bin/sh, val open_process_in : string -> Pervasives cf. system

. Val and . Pervasives, out_channel Same as Unix.open_process_in[28.1], but redirect the standard input of the command to a pipe. Data written to the returned output channel is sent to the standard input of the command. Warning: writes on output channels are buffered, hence be careful to call Pervasives

, val open_process : string -> Pervasives.in_channel * Pervasives.out_channel Same as Unix.open_process_out[28.1], but redirects both the standard input and standard output of the command to pipes connected to the two returned channels. The input channel is connected to the output of the command

, val open_process_full : string -> string array -> Pervasives.in_channel * Pervasives.out_channel * Pervasives.in_channel Similar to Unix.open_process[28.1], but the second argument specifies the environment passed to the command. The result is a triple of channels connected respectively to the standard output, standard input, and standard error of the command

, val close_process_in : Pervasives.in_channel -> process_status Close channels opened by Unix.open_process_in[28.1], wait for the associated command to terminate, and return its termination status

, val close_process_out : Pervasives.out_channel -> process_status Close channels opened by Unix.open_process_out[28.1], wait for the associated command to terminate, and return its termination status

, val close_process : Pervasives.in_channel * Pervasives.out_channel -> process_status Close channels opened by Unix.open_process[28.1], wait for the associated command to terminate, and return its termination status

, val close_process_full : Pervasives.in_channel * Pervasives.out_channel * Pervasives.in_channel -> process_status Return the current time since 00:00:00 GMT, 1970.

, val gettimeofday : unit -> float Same as Unix.time[28.1], but with resolution better than 1 second

. Val-gmtime, Convert a time in seconds, as returned by Unix.time[28.1], into a date and a time Assumes UTC (Coordinated Universal Time), also known as GMT. To perform the inverse conversion, set the TZ environment variable to " UTC, use Unix.mktime[28.1], and then restore the original value of TZ

. Val-localtime, float -> tm Convert a time in seconds, as returned by Unix.time[28.1], into a date and a time. Assumes the local time zone. The function performing the inverse conversion is Unix

. Val-mktime, tm -> float * tm Convert a date and time, specified by the tm argument, into a time in seconds, as returned by Unix.time[28.1]. The tm_isdst, tm_wday and tm_yday fields of tm are ignored. Also return a normalized copy of the given tm record, with the tm_wday, tm_yday, and tm_isdst fields recomputed from the other fields, and the other fields normalized, p.40

, The tm argument is interpreted in the local time zone. val alarm : int -> int Schedule a SIGALRM signal after the given number of seconds

, On Windows: not implemented. val sleep : int -> unit Stop execution for the given number of seconds

, val sleepf : float -> unit Stop execution for the given number of seconds. Like sleep, but fractions of seconds are supported

, val times : unit -> process_times Return the execution times of the process. On Windows, it is partially implemented, will not report timings for child processes

, val utimes : string -> float -> float -> unit Set the last access time (second arg) and last modification time (third arg) for a file. Times are expressed in seconds from 00:00:00 GMT If both times are 0.0, the access and last modification times are both set to the current time, 1970.

=. Type-interval_timer, file_descr -> socket_bool_option -> bool Return the current status of a boolean-valued option in the given socket

, val setsockopt : file_descr -> socket_bool_option -> bool -> unit Set or clear a boolean-valued option in the given socket

, val getsockopt_int : file_descr -> socket_int_option -> int Same as Unix.getsockopt[28.1] for an integer-valued socket option

, val setsockopt_int : file_descr -> socket_int_option -> int -> unit Same as Unix.setsockopt[28.1] for an integer-valued socket option

, val getsockopt_optint : file_descr -> socket_optint_option -> int option Same as Unix.getsockopt[28.1] for a socket option whose value is an int option

, val setsockopt_optint : file_descr -> socket_optint_option -> int option -> unit Same as Unix.setsockopt[28.1] for a socket option whose value is an int option

, val getsockopt_float : file_descr -> socket_float_option -> float Same as Unix.getsockopt[28.1] for a socket option whose value is a floating-point number, Ignore modem status lines

, mutable c_isig : bool ; Generate signal on INTR

, mutable c_icanon : bool ; Enable canonical processing (line buffering and editing)

, mutable c_noflsh : bool ; Disable flush after INTR

, mutable c_echo : bool ; Echo input characters

, mutable c_echoe : bool ; Echo ERASE (to erase previous character)

, mutable c_echok : bool ; Echo KILL (to erase the current line)

, mutable c_echonl : bool ; Echo NL even if c_echo is not set

, mutable c_vintr : char ; Interrupt character (usually ctrl-C)

, mutable c_vquit : char ; Quit character (usually ctrl- " )

, mutable c_verase : char ; Erase character (usually DEL or ctrl-H)

, mutable c_vkill : char ; Kill line character (usually ctrl-U)

, mutable c_veof : char ; End-of-file character (usually ctrl-D)

, mutable c_veol : char ; Alternate end-of-line char. (usually none)

, mutable c_vmin : int ; Minimum number of characters to read before the read request is satisfied

, mutable c_vtime : int ; Maximum read wait (in 0.1s units)

, mutable c_vstart : char ; Start character (usually ctrl-Q)

, mutable c_vstop : char

@. , Matches the preceding expression one or several times ? ? (postfix) Matches the preceding expression once or not at all ? [..] Character set. Ranges are denoted with -, as in [a-z]. An initial ^, as in [^0-9], complements the set. To include a ] character in a set, make it the first character of the set

@. ^. , Matches at beginning of line: either at the beginning of the matched string, or just after a

@. $. , Matches at end of line: either at the end of the matched string, or just before a

, ? \| (infix) Alternative between two expressions

@. , \) Grouping and naming of the enclosed expression

, ? \1 The text matched by the first \(...\) expression (\2 for the second expression, and so on up to \9)

, ? \b Matches word boundaries

, ? \ Quotes special characters. The special characters are $^\

, Note: the argument to regexp is usually a string literal In this case, any backslash character in the regular expression must be doubled to make it past the OCaml string parser. For example, the following expression: let r = Str.regexp "hello \\([A-Za-z]+\\, Str.replace_first r "\\1" "hello world" returns the string "world

, you need to quote it in the argument to regexp (according to the last item of the list above) by adding a second backslash. Then you need to quote both backslashes (according to the syntax of string constants in OCaml) by doubling them again, so you need to write four backslash characters

, val regexp_case_fold : string -> regexp Same as regexp, but the compiled expression will match text in a case-insensitive way: uppercase and lowercase letters will be considered equivalent

, val quote : string -> string Str.quote s returns a regexp string that matches exactly s and nothing else

, val regexp_string : string -> regexp Str.regexp_string s returns a regular expression that matches exactly s and nothing else

, val regexp_string_case_fold : string -> regexp Str.regexp_string_case_fold is similar to Str.regexp_string[30.1], but the regexp matches in a case-insensitive way

, file_descr -> bytes -> int -> int -> int val write : Unix.file_descr -> bytes -> int -> int -> int val single_write : Unix.file_descr -> bytes -> int -> int -> int val write_substring : Unix.file_descr -> string -> int -> int -> int val single_write_substring : Unix.file_descr -> string -> int -> int -> int

, Input/output with timeout val timed_read : Unix.file_descr -> bytes -> int -> int -> float -> int See ThreadUnix

. Val and . Unix, file_descr -> bytes -> int -> int -> float -> int Behave as ThreadUnix.read[31.5] and ThreadUnix.write[31.5], except that Unix_error(ETIMEDOUT,_,_) is raised if no data is available for reading or ready for writing after d seconds. The delay d is given in the fifth argument

. Val and . Unix, file_descr -> string -> int -> int -> float -> int See ThreadUnix

. Unix, *. File_descr-list, . Unix, . File_descr, and . Unix, file_descr list Pipes and redirections val pipe : ?cloexec:bool -> unit -> Unix.file_descr * Unix.file_descr val open_process_in : string -> Pervasives.in_channel val open_process_out : string -> Pervasives.out_channel val open_process : string -> Pervasives.in_channel * Pervasives.out_channel val open_process_full : string -> string array -> Pervasives.in_channel * Pervasives.out_channel * Pervasives.in_channel Time val sleep : int -> unit Sockets val socket : ?cloexec:bool -> Unix.socket_domain -> Unix.socket_type -> int -> Unix.file_descr val socketpair : ?cloexec:bool -> Unix.socket_domain -> Unix.socket_type -> int -> Unix.file_descr * Unix.file_descr val accept : ?cloexec:bool -> Unix.file_descr -> Unix.file_descr * Unix.sockaddr val connect : Unix.file_descr -> Unix.sockaddr -> unit val recv : Unix.file_descr -> bytes -> int -> int -> Unix.msg_flag list -> int val recvfrom : Unix.file_descr -> bytes -> int -> int -> Unix.msg_flag list -> int * Unix.sockaddr val send : Unix.file_descr -> bytes -> int -> int -> Unix.msg_flag list -> int val send_substring : Unix.file_descr -> string -> int -> int -> Unix.msg_flag list -> int val sendto : Unix.file_descr -> bytes -> int -> int -> Unix, msg_flag list -> Unix.sockaddr -> int val sendto_substring : Unix.file_descr -> string -> int -> int -> Unix.msg_flag list -> Unix.sockaddr -> int val open_connection : Unix.sockaddr -> Pervasives.in_channel * Pervasives.out_channel val establish_server : (Pervasives.in_channel -> Pervasives.out_channel -> unit) -> Unix.sockaddr -> unit Resize and erase the graphics window

, val clear_graph : unit -> unit Erase the graphics window

, val size_x : unit -> int See Graphics.size_y[32

, Coordinates of the screen pixels range over 0 .. size_x()-1 and 0 .. size_y()-1. Drawings outside of this rectangle are clipped, without causing an error. The origin (0,0) is at the lower left corner. Some implementation (e.g. X Windows) represent coordinates by 16-bit integers, val size_y : unit -> int Return the

R. and G. , Colors type color = int A color is Each component is in the range 0..255. The three components are packed in an int: 0xRRGGBB, where RR are the two hexadecimal digits for the red component, GG for the green component, BB for the blue component

V. Rgb, int -> int -> int -> color rgb r g b returns the integer encoding the color with red component r, green component g, and blue component b. r, g and b are in the range 0

, val set_color : color -> unit Set the current drawing color

, val background : color See Graphics

, val foreground : color Default background and foreground colors (usually, either black foreground on a white background or white foreground on a black background). Graphics.clear_graph[32.1] fills the screen with the background color. The initial drawing color is foreground

, Some predefined colors val black : color val white : color val red : color val green : color val blue : color val yellow : color val cyan : color val magenta : color Set the font used for drawing text. The interpretation of the argument to set_font is implementation-dependent

, val set_text_size : int -> unit Set the character size used for drawing text. The interpretation of the argument to set_text_size is implementation-dependent

, val text_size : string -> int * int Return the dimensions of the given text, if it were drawn with the current font and size

. Filling-val-fill_rect, int -> int -> int -> int -> unit fill_rect x y w h fills the rectangle with lower left corner at x,y, width w and height h, with the current color

V. Fill_poly, (int * int) array -> unit Fill the given polygon with the current color. The array contains the coordinates of the vertices of the polygon

V. Fill_arc, int -> int -> int -> int -> int -> int -> unit Fill an elliptical pie slice with the current color. The parameters are the same as for Graphics

. Val-fill_ellipse, int -> int -> int -> int -> unit Fill an ellipse with the current color. The parameters are the same as for Graphics

. Val-fill_circle, int -> int -> int -> unit Fill a circle with the current color. The parameters are the same as for Graphics