diff6-10.chapter20.txtこのページは最後に更新されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。 last mod. 2008-08-28 (木) 09:56:17
11c11 < standard library are not automatically ``opened'' when a compilation starts, or --- > standard library are not automatically "opened" when a compilation starts, or 16a17 > 32,33c33,34 < This module provides a general mechanism for extracting options and < arguments from the command line to the program. --- > This module provides a general mechanism for extracting options and arguments > from the command line to the program. 36,40c37,41 < are: Unit, Set, Clear, String, Int, Float, and Rest. Unit, Set and Clear < keywords take no argument. String, Int, and Float keywords take the following < word on the command line as an argument. A Rest keyword takes the remaining of < the command line as (string) arguments. Arguments not preceded by a keyword < are called anonymous arguments. --- > are: Unit, Bool, Set, Clear, String, Set_string, Int, Set_int, Float, > Set_float, Tuple, Symbol, and Rest. Unit, Set and Clear keywords take no > argument. A Rest keyword takes the remaining of the command line as arguments. > Every other keyword takes the following word on the command line as argument. > Arguments not preceded by a keyword are called anonymous arguments. 53d53 < 61a62,67 > | Bool of (bool -> unit) > >> > > Call the function with a bool argument > > << 79a86,91 > | Set_string of string Pervasives.ref > >> > > Set the reference to the string argument > > << 85a98,103 > | Set_int of int Pervasives.ref > >> > > Set the reference to the int argument > > << 91a110,127 > | Set_float of float Pervasives.ref > >> > > Set the reference to the float argument > > << > | Tuple of spec list > >> > > Take several arguments according to the spec list > > << > | Symbol of string list * (string -> unit) > >> > > Take one of the symbols as argument and call the function with the symbol > > << 95,96c131,132 < Stop interpreting keywords and call the function with each < remaining argument --- > Stop interpreting keywords and call the function with each remaining > argument 101,102c137 < val parse : < (string * spec * string) list -> (string -> unit) -> string -> unit --- > type key = string 105,114c140,142 < Arg.parse speclist anonfun usage_msg parses the command line. < speclist is a list of triples (key, spec, doc). key is the < option keyword, it must start with a '-' character. spec gives < the option type and the function to call when this option is < found on the command line. doc is a one-line description of < this option. anonfun is called on anonymous arguments. The < functions in spec and anonfun are called in the same order as < their arguments appear on the command line. < If an error occurs, Arg.parse exits the program, after printing < an error message as follows: --- > << > type doc = string > >> 116,120c144,146 < - The reason for the error: unknown option, invalid or missing < argument, etc. < - usage_msg < - The list of options, each followed by the corresponding doc < string. --- > << > type usage_msg = string > >> 122,128c148,154 < For the user to be able to specify anonymous arguments starting < with a -, include for example ("-", String anonfun, doc) in < speclist. < By default, parse recognizes two unit options, -help and --help, < which will display usage_msg and the list of options, and exit < the program. You can override this behaviour by specifying your < own -help and --help options in speclist. --- > << > type anon_fun = string -> unit > >> > > << > val parse : (key * spec * doc) list -> anon_fun -> usage_msg -> unit > >> 129a156,169 > Arg.parse speclist anon_fun usage_msg parses the command line. speclist is > a list of triples (key, spec, doc). key is the option keyword, it must start > with a '-' character. spec gives the option type and the function to call > when this option is found on the command line. doc is a one-line description > of this option. anon_fun is called on anonymous arguments. The functions in > spec and anon_fun are called in the same order as their arguments appear on > the command line. > If an error occurs, Arg.parse exits the program, after printing an error > message as follows: > > - The reason for the error: unknown option, invalid or missing argument, > etc. > - usage_msg > - The list of options, each followed by the corresponding doc string. 130a171,176 > For the user to be able to specify anonymous arguments starting with a -, > include for example ("-", String anon_fun, doc) in speclist. > By default, parse recognizes two unit options, -help and --help, which will > display usage_msg and the list of options, and exit the program. You can > override this behaviour by specifying your own -help and --help options in > speclist. 133a180 > ?current:int Pervasives.ref -> 135c182 < (string * spec * string) list -> (string -> unit) -> string -> unit --- > (key * spec * doc) list -> anon_fun -> usage_msg -> unit 138,139c185,191 < Arg.parse_argv args speclist anonfun usage_msg parses array < args as if it were the command line. --- > Arg.parse_argv ~current args speclist anon_fun usage_msg parses the array > args as if it were the command line. It uses and updates the value of > ~current (if given), or Arg.current. You must set it before calling > parse_argv. The initial value of current is the index of the program name > (argument 0) in the array. If an error occurs, Arg.parse_argv raises Arg.Bad > with the error message as argument. If option -help or --help is given, > Arg.parse_argv raises Arg.Help with the help message as argument. 140a193,195 > << > exception Help of string > >> 141a197 > Raised by Arg.parse_argv when the user asks for help. 147,150c203,205 < Functions in spec or anonfun can raise Arg.Bad with an error < message to reject invalid arguments. < < --- > Functions in spec or anon_fun can raise Arg.Bad with an error message to > reject invalid arguments. Arg.Bad is also raised by Arg.parse_argv in case > of an error. 153c208 < val usage : (string * spec * string) list -> string -> unit --- > val usage : (key * spec * doc) list -> usage_msg -> unit 156,159c211,213 < Arg.usage speclist usage_msg prints an error message including < the list of valid options. This is the same message that < Arg.parse[20.1] prints in case of error. speclist and usage_msg < are the same as for Arg.parse. --- > Arg.usage speclist usage_msg prints an error message including the list of > valid options. This is the same message that Arg.parse[20.1] prints in case > of error. speclist and usage_msg are the same as for Arg.parse. 160a215,217 > << > val align : (key * spec * doc) list -> (key * spec * doc) list > >> 161a219,222 > Align the documentation strings by inserting spaces at the first space, > according to the length of the keyword. Use a space as the first character > in a doc string if you want to align the whole string. The doc strings > corresponding to Symbol arguments are not aligned. 167,170c228,232 < Position (in Sys.argv[20.34]) of the argument being processed. < You can change this value, e.g. to force Arg.parse[20.1] to < skip some arguments. < --- > Position (in Sys.argv[20.34]) of the argument being processed. You can > change this value, e.g. to force Arg.parse[20.1] to skip some arguments. > Arg.parse[20.1] uses the initial value of Arg.current[20.1] as the index of > argument 0 (the program name) and starts parsing arguments at the next > element. 180d241 < 187,188d247 < < 193,200c252,256 < Array.get a n returns the element number n of array a. The < first element has number 0. The last element has number < Array.length a - 1. < Raise Invalid_argument "Array.get" if n is outside the range 0 < to (Array.length a - 1). You can also write a.(n) instead of < Array.get a n. < < --- > Array.get a n returns the element number n of array a. The first element > has number 0. The last element has number Array.length a - 1. You can also > write a.(n) instead of Array.get a n. > Raise Invalid_argument "index out of bounds" if n is outside the range 0 to > (Array.length a - 1). 206,212c262,265 < Array.set a n x modifies array a in place, replacing element < number n with x. < Raise Invalid_argument "Array.set" if n is outside the range 0 < to Array.length a - 1. You can also write a.(n) <- x instead of < Array.set a n x. < < --- > Array.set a n x modifies array a in place, replacing element number n with > x. You can also write a.(n) <- x instead of Array.set a n x. > Raise Invalid_argument "index out of bounds" if n is outside the range 0 to > Array.length a - 1. 218,228c271,278 < Array.make n x returns a fresh array of length n, initialized < with x. All the elements of this new array are initially < physically equal to x (in the sense of the == predicate). < Consequently, if x is mutable, it is shared among all elements < of the array, and modifying x through one of the array entries < will modify all other entries at the same time. < Raise Invalid_argument if n < 0 or n > Sys.max_array_length. If < the value of x is a floating-point number, then the maximum < size is only Sys.max_array_length / 2. < < --- > Array.make n x returns a fresh array of length n, initialized with x. All > the elements of this new array are initially physically equal to x (in the > sense of the == predicate). Consequently, if x is mutable, it is shared > among all elements of the array, and modifying x through one of the array > entries will modify all other entries at the same time. > Raise Invalid_argument if n < 0 or n > Sys.max_array_length. If the value of > x is a floating-point number, then the maximum size is only > Sys.max_array_length / 2. 236d285 < 241,249c290,294 < Array.init n f returns a fresh array of length n, with element < number i initialized to the result of f i. In other terms, < Array.init n f tabulates the results of f applied to the < integers 0 to n-1. < Raise Invalid_argument if n < 0 or n > Sys.max_array_length. If < the return type of f is float, then the maximum size is only < Sys.max_array_length / 2. < < --- > Array.init n f returns a fresh array of length n, with element number i > initialized to the result of f i. In other terms, Array.init n f tabulates > the results of f applied to the integers 0 to n-1. > Raise Invalid_argument if n < 0 or n > Sys.max_array_length. If the return > type of f is float, then the maximum size is only Sys.max_array_length / 2. 255,265c300,306 < Array.make_matrix dimx dimy e returns a two-dimensional array < (an array of arrays) with first dimension dimx and second < dimension dimy. All the elements of this new matrix are < initially physically equal to e. The element (x,y) of a matrix < m is accessed with the notation m.(x).(y). < Raise Invalid_argument if dimx or dimy is negative or greater < than Sys.max_array_length. If the value of e is a < floating-point number, then the maximum size is only < Sys.max_array_length / 2. < < --- > Array.make_matrix dimx dimy e returns a two-dimensional array (an array of > arrays) with first dimension dimx and second dimension dimy. All the > elements of this new matrix are initially physically equal to e. The element > (x,y) of a matrix m is accessed with the notation m.(x).(y). > Raise Invalid_argument if dimx or dimy is negative or greater than > Sys.max_array_length. If the value of e is a floating-point number, then the > maximum size is only Sys.max_array_length / 2. 271,273c312 < Deprecated. Array.create_matrix is an alias for < Array.make_matrix[20.2]. < --- > Deprecated. Array.create_matrix is an alias for Array.make_matrix[20.2]. 279,282c318,319 < Array.append v1 v2 returns a fresh array containing the < concatenation of the arrays v1 and v2. < < --- > Array.append v1 v2 returns a fresh array containing the concatenation of > the arrays v1 and v2. 290,291d326 < < 296,303c331,335 < Array.sub a start len returns a fresh array of length len, < containing the elements number start to start + len - 1 of < array a. < Raise Invalid_argument "Array.sub" if start and len do not < designate a valid subarray of a; that is, if start < 0, or len < < 0, or start + len > Array.length a. < < --- > Array.sub a start len returns a fresh array of length len, containing the > elements number start to start + len - 1 of array a. > Raise Invalid_argument "Array.sub" if start and len do not designate a valid > subarray of a; that is, if start < 0, or len < 0, or start + len > > Array.length a. 309,312c341,342 < Array.copy a returns a copy of a, that is, a fresh array < containing the same elements as a. < < --- > Array.copy a returns a copy of a, that is, a fresh array containing the > same elements as a. 318,323c348,351 < Array.fill a ofs len x modifies the array a in place, storing < x in elements number ofs to ofs + len - 1. < Raise Invalid_argument "Array.fill" if ofs and len do not < designate a valid subarray of a. < < --- > Array.fill a ofs len x modifies the array a in place, storing x in elements > number ofs to ofs + len - 1. > Raise Invalid_argument "Array.fill" if ofs and len do not designate a valid > subarray of a. 329,337c357,362 < Array.blit v1 o1 v2 o2 len copies len elements from array v1, < starting at element number o1, to array v2, starting at element < number o2. It works correctly even if v1 and v2 are the same < array, and the source and destination chunks overlap. < Raise Invalid_argument "Array.blit" if o1 and len do not < designate a valid subarray of v1, or if o2 and len do not < designate a valid subarray of v2. < < --- > Array.blit v1 o1 v2 o2 len copies len elements from array v1, starting at > element number o1, to array v2, starting at element number o2. It works > correctly even if v1 and v2 are the same array, and the source and > destination chunks overlap. > Raise Invalid_argument "Array.blit" if o1 and len do not designate a valid > subarray of v1, or if o2 and len do not designate a valid subarray of v2. 345,346d369 < < 351,354c374 < Array.of_list l returns a fresh array containing the elements < of l. < < --- > Array.of_list l returns a fresh array containing the elements of l. 360,364c380,381 < Array.iter f a applies function f in turn to all the elements < of a. It is equivalent to f a.(0); f a.(1); ...; f < a.(Array.length a - 1); (). < < --- > Array.iter f a applies function f in turn to all the elements of a. It is > equivalent to f a.(0); f a.(1); ...; f a.(Array.length a - 1); (). 370,374c387,389 < 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.(0); f < a.(1); ...; f a.(Array.length a - 1) |]. < < --- > 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.(0); f a.(1); ...; f > a.(Array.length a - 1) |]. 380,384c395,396 < Same as Array.iter[20.2], but the function is applied to the < index of the element as first argument, and the element itself < as second argument. < < --- > Same as Array.iter[20.2], but the function is applied to the index of the > element as first argument, and the element itself as second argument. 390,394c402,403 < Same as Array.map[20.2], but the function is applied to the < index of the element as first argument, and the element itself < as second argument. < < --- > Same as Array.map[20.2], but the function is applied to the index of the > element as first argument, and the element itself as second argument. 400,403c409,410 < Array.fold_left f x a computes f (... (f (f x a.(0)) a.(1)) < ...) a.(n-1), where n is the length of the array a. < < --- > Array.fold_left f x a computes f (... (f (f x a.(0)) a.(1)) ...) a.(n-1), > where n is the length of the array a. 409,410c416,417 < Array.fold_right f a x computes f a.(0) (f a.(1) ( ... (f < a.(n-1) x) ...)), where n is the length of the array a. --- > Array.fold_right f a x computes f a.(0) (f a.(1) ( ... (f a.(n-1) x) ...)), > where n is the length of the array a. 417d423 < 422,436c428,438 < Sort an array 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 below for a < complete specification). For example, Pervasives.compare[19.2] < is a suitable comparison function, provided there are no < floating-point NaN values in the data. After calling < Array.sort, the array is sorted in place in increasing order. < Array.sort is guaranteed to run in constant heap space and (at < most) logarithmic stack space. < The current implementation uses Heap Sort. It runs in constant < stack space. < Specification of the comparison function: Let a be the array < and cmp the comparison function. The following must be true for < all x, y, z in a : --- > Sort an array 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 below for a complete specification). For example, > Pervasives.compare[19.2] is a suitable comparison function, provided there > are no floating-point NaN values in the data. After calling Array.sort, the > array is sorted in place in increasing order. Array.sort is guaranteed to > run in constant heap space and (at most) logarithmic stack space. > The current implementation uses Heap Sort. It runs in constant stack space. > Specification of the comparison function: Let a be the array and cmp the > comparison function. The following must be true for all x, y, z in a : 441,443c443,444 < When Array.sort returns, a contains the same elements as before, < reordered in such a way that for all i and j valid indices of a < : --- > When Array.sort returns, a contains the same elements as before, reordered > in such a way that for all i and j valid indices of a : 448d448 < 453,461c453,458 < Same as Array.sort[20.2], but the sorting algorithm is stable < (i.e. elements that compare equal are kept in their original < order) and not guaranteed to run in constant heap space. < The current implementation uses Merge Sort. It uses n/2 words < of heap space, where n is the length of the array. It is < usually faster than the current implementation of < Array.sort[20.2]. < < --- > Same as Array.sort[20.2], but the sorting algorithm is stable (i.e. > elements that compare equal are kept in their original order) and not > guaranteed to run in constant heap space. > The current implementation uses Merge Sort. It uses n/2 words of heap space, > where n is the length of the array. It is usually faster than the current > implementation of Array.sort[20.2]. 467,469c464,465 < Same as Array.sort[20.2] or Array.stable_sort[20.2], whichever < is faster on typical input. < --- > Same as Array.sort[20.2] or Array.stable_sort[20.2], whichever is faster on > typical input. 477,480c473,475 < This module implements string buffers that automatically expand as < necessary. It provides accumulative concatenation of strings in quasi-linear < time (instead of quadratic time when strings are concatenated pairwise). < --- > This module implements string buffers that automatically expand as necessary. > It provides accumulative concatenation of strings in quasi-linear time (instead > of quadratic time when strings are concatenated pairwise). 489,490d483 < < 495,505c488,496 < create n returns a fresh buffer, initially empty. The n < parameter is the initial size of the internal string that holds < the buffer contents. That string is automatically reallocated < when more than n characters are stored in the buffer, but < shrinks back to n characters when reset is called. For best < performance, n should be of the same order of magnitude as the < number of characters that are expected to be stored in the < buffer (for instance, 80 for a buffer that holds one output < line). Nothing bad will happen if the buffer grows beyond that < limit, however. In doubt, take n = 16 for instance. If n is not < between 1 and Sys.max_string_length[20.34], it will be clipped --- > create n returns a fresh buffer, initially empty. The n parameter is the > initial size of the internal string that holds the buffer contents. That > string is automatically reallocated when more than n characters are stored > in the buffer, but shrinks back to n characters when reset is called. For > best performance, n should be of the same order of magnitude as the number > of characters that are expected to be stored in the buffer (for instance, 80 > for a buffer that holds one output line). Nothing bad will happen if the > buffer grows beyond that limit, however. In doubt, take n = 16 for instance. > If n is not between 1 and Sys.max_string_length[20.34], it will be clipped 508,509d498 < < 514,515c503,504 < Return a copy of the current contents of the buffer. The < buffer itself is unchanged. --- > Return a copy of the current contents of the buffer. The buffer itself is > unchanged. 516a506,508 > << > val sub : t -> int -> int -> string > >> 517a510,513 > Buffer.sub b off len returns (a copy of) the substring of the current > contents of the buffer b starting at offset off of length len bytes. May > raise Invalid_argument if out of bounds request. The buffer itself is > unaffected. 520c516 < val length : t -> int --- > val nth : t -> int -> char 523,524c519,520 < Return the number of characters currently contained in the < buffer. --- > get the n-th character of the buffer. Raise Invalid_argument if index out > of bounds 525a522,524 > << > val length : t -> int > >> 526a526 > Return the number of characters currently contained in the buffer. 534,535d533 < < 540,546c538,542 < Empty the buffer and deallocate the internal string holding the < buffer contents, replacing it with the initial internal string < of length n that was allocated by Buffer.create[20.3] n. For < long-lived buffers that may have grown a lot, reset allows < faster reclaimation of the space used by the buffer. < < --- > Empty the buffer and deallocate the internal string holding the buffer > contents, replacing it with the initial internal string of length n that was > allocated by Buffer.create[20.3] n. For long-lived buffers that may have > grown a lot, reset allows faster reclamation of the space used by the > buffer. 552,555c548 < add_char b c appends the character c at the end of the buffer < b. < < --- > add_char b c appends the character c at the end of the buffer b. 563,564d555 < < 569,570c560,561 < add_substring b s ofs len takes len characters from offset ofs < in string s and appends them at the end of the buffer b. --- > add_substring b s ofs len takes len characters from offset ofs in string s > and appends them at the end of the buffer b. 571a563,579 > << > val add_substitute : t -> (string -> string) -> string -> unit > >> > > add_substitute b f s appends the string pattern s at the end of the buffer > b with substitution. The substitution process looks for variables into the > pattern and substitutes each variable name by its value, as obtained by > applying the mapping f to the variable name. Inside the string pattern, a > variable name immediately follows a non-escaped $ character and is one of > the following: > > - a non empty sequence of alphanumeric or _ characters, > - an arbitrary sequence of characters enclosed by a pair of matching > parentheses or curly brackets. An escaped $ character is a $ that > immediately follows a backslash character; it then stands for a plain $. > Raise Not_found if the closing character of a parenthesized variable > cannot be found. 578,581c586,587 < add_buffer b1 b2 appends the current contents of buffer b2 at < the end of buffer b1. b2 is not modified. < < --- > add_buffer b1 b2 appends the current contents of buffer b2 at the end of > buffer b1. b2 is not modified. 587,591c593,595 < add_channel b ic n reads exactly n character from the input < channel ic and stores them at the end of buffer b. Raise < End_of_file if the channel contains fewer than n characters. < < --- > add_channel b ic n reads exactly n character from the input channel ic and > stores them at the end of buffer b. Raise End_of_file if the channel > contains fewer than n characters. 597,599c601,602 < output_buffer oc b writes the current contents of buffer b on < the output channel oc. < --- > output_buffer oc b writes the current contents of buffer b on the output > channel oc. 608,610c611,612 < symbolic name, so that C code can later call back registered Caml functions, < or raise registered Caml exceptions. < --- > symbolic name, so that C code can later call back registered Caml functions, or > raise registered Caml exceptions. 617,621c619,620 < Callback.register n v registers the value v under the name n. < C code can later retrieve a handle to v by calling < caml_named_value(n). < < --- > Callback.register n v registers the value v under the name n. C code can > later retrieve a handle to v by calling caml_named_value(n). 627,631c626,629 < Callback.register_exception n exn registers the exception < contained in the exception value exn under the name n. C code < can later retrieve a handle to the exception by calling < caml_named_value(n). The exception value thus obtained is < suitable for passign as first argument to raise_constant or --- > Callback.register_exception n exn registers the exception contained in the > exception value exn under the name n. C code can later retrieve a handle to > the exception by calling caml_named_value(n). The exception value thus > obtained is suitable for passign as first argument to raise_constant or 636d633 < 643d639 < 650,651d645 < < 656,660c650,651 < Return the character with the given ASCII code. Raise < Invalid_argument "Char.chr" if the argument is outside the < range 0--255. < < --- > Return the character with the given ASCII code. Raise Invalid_argument > "Char.chr" if the argument is outside the range 0--255. 666,670c657,658 < Return a string representing the given character, with special < characters escaped following the lexical conventions of < Objective Caml. < < --- > Return a string representing the given character, with special characters > escaped following the lexical conventions of Objective Caml. 676,679c664 < Convert the given character to its equivalent lowercase < character. < < --- > Convert the given character to its equivalent lowercase character. 685,688c670 < Convert the given character to its equivalent uppercase < character. < < --- > Convert the given character to its equivalent uppercase character. 696,697d677 < < 702,707c682,685 < The comparison function for characters, with the same < specification as Pervasives.compare[19.2]. Along with the type < t, this function compare allows the module Char to be passed as < argument to the functors Set.Make[20.28.3] and < Map.Make[20.18.3]. < --- > The comparison function for characters, with the same specification as > Pervasives.compare[19.2]. Along with the type t, this function compare > allows the module Char to be passed as argument to the functors > Set.Make[20.28] and Map.Make[20.18]. 721d698 < 729,732c706 < The type of complex numbers. re is the real part and im the < imaginary part. < < --- > The type of complex numbers. re is the real part and im the imaginary part. 740,741d713 < < 748,749d719 < < 756,757d725 < < 764,765d731 < < 772,773d737 < < 780,781d743 < < 788,789d749 < < 796,797d755 < < 804,805d761 < < 812,813d767 < < 818,822c772,773 < Square root. The result x + i.y is such that x > 0 or x = 0 < and y >= 0. This function has a discontinuity along the < negative real axis. < < --- > Square root. The result x + i.y is such that x > 0 or x = 0 and y >= 0. > This function has a discontinuity along the negative real axis. 830,831d780 < < 838,839d786 < < 844,849c791,794 < Argument. The argument of a complex number is the angle in the < complex plane between the positive real axis and a line passing < through zero and the number. This angle ranges from -pi to pi. < This function has a discontinuity along the negative real axis. < < --- > Argument. The argument of a complex number is the angle in the complex > plane between the positive real axis and a line passing through zero and the > number. This angle ranges from -pi to pi. This function has a discontinuity > along the negative real axis. 855,858c800 < polar norm arg returns the complex having norm norm and < argument arg. < < --- > polar norm arg returns the complex having norm norm and argument arg. 866,867d807 < < 874,875d813 < < 884d821 < 889,891c826,828 < This module provides functions to compute 128-bit ``digests'' of < arbitrary-length strings or files. The digests are of cryptographic quality: < it is very hard, given a digest, to forge a string having that digest. The --- > This module provides functions to compute 128-bit "digests" of > arbitrary-length strings or files. The digests are of cryptographic quality: it > is very hard, given a digest, to forge a string having that digest. The 895d831 < 902,903d837 < < 910,911d843 < < 916,920c848,849 < Digest.substring s ofs len returns the digest of the substring < of s starting at character number ofs and containing len < characters. < < --- > Digest.substring s ofs len returns the digest of the substring of s > starting at character number ofs and containing len characters. 926,930c855,858 < If len is nonnegative, Digest.channel ic len reads len < characters from channel ic and returns their digest, or raises < End_of_file if end-of-file is reached before len characters are < read. If len is negative, Digest.channel ic len reads all < characters from ic until end-of-file is reached and return --- > If len is nonnegative, Digest.channel ic len reads len characters from > channel ic and returns their digest, or raises End_of_file if end-of-file is > reached before len characters are read. If len is negative, Digest.channel > ic len reads all characters from ic until end-of-file is reached and return 933,934d860 < < 941,942d866 < < 949,950d872 < < 957,958d878 < < 963,965c883 < Return the printable hexadecimal representation of the given < digest. < --- > Return the printable hexadecimal representation of the given digest. 975d892 < 980,983c897 < The conventional name for the current directory (e.g. . in < Unix). < < --- > The conventional name for the current directory (e.g. . in Unix). 989,992c903,904 < The conventional name for the parent of the current directory < (e.g. .. in Unix). < < --- > The conventional name for the parent of the current directory (e.g. .. in > Unix). 998,1001c910,911 < concat dir file returns a file name that designates file file < in directory dir. < < --- > concat dir file returns a file name that designates file file in directory > dir. 1007,1011c917,918 < Return true if the file name is relative to the current < directory, false if it is absolute (i.e. in Unix, starts with < /). < < --- > Return true if the file name is relative to the current directory, false if > it is absolute (i.e. in Unix, starts with /). 1017,1022c924,927 < Return true if the file name is relative and does not start < with an explicit reference to the current directory (./ or ../ < in Unix), false if it starts with an explicit reference to the < root directory or the current directory. < < --- > Return true if the file name is relative and does not start with an > explicit reference to the current directory (./ or ../ in Unix), false if it > starts with an explicit reference to the root directory or the current > directory. 1028,1031c933,934 < check_suffix name suff returns true if the filename name ends < with the suffix suff. < < --- > check_suffix name suff returns true if the filename name ends with the > suffix suff. 1037,1041c940,941 < chop_suffix name suff removes the suffix suff from the < filename name. The behavior is undefined if name does not end < with the suffix suff. < < --- > chop_suffix name suff removes the suffix suff from the filename name. The > behavior is undefined if name does not end with the suffix suff. 1047,1053c947,950 < Return the given file name without its extension. The extension < is the shortest suffix starting with a period, .xyz for < instance. < Raise Invalid_argument if the given name does not contain a < period. < < --- > Return the given file name without its extension. The extension is the > shortest suffix starting with a period and not including a directory > separator, .xyz for instance. > Raise Invalid_argument if the given name does not contain an extension. 1059,1066c956,962 < Split a file name into directory name / base file name. concat < (dirname name) (basename name) returns a file name which is < equivalent to name. Moreover, after setting the current < directory to dirname name (with Sys.chdir[20.34]), references < to basename name (which is a relative file name) designate the < same file as name before the call to Sys.chdir[20.34]. < < --- > Split a file name into directory name / base file name. concat (dirname > name) (basename name) returns a file name which is equivalent to name. > Moreover, after setting the current directory to dirname name (with > Sys.chdir[20.34]), references to basename name (which is a relative file > name) designate the same file as name before the call to Sys.chdir[20.34]. > The result is not specified if the argument is not a valid file name (for > example, under Unix if there is a NUL character in the string). 1074,1075d969 < < 1080,1095c974,979 < temp_file prefix suffix returns the name of a fresh temporary < file in the temporary directory. The base name of the temporary < file is formed by concatenating prefix, then a suitably chosen < integer number, then suffix. The temporary file is created < empty, with permissions 0o600 (readable and writable only by < the file owner). The file is guaranteed to be different from < any other file that existed when temp_file was called. Under < Unix, the temporary directory is /tmp by default; if set, the < value of the environment variable TMPDIR is used instead. Under < Windows, the name of the temporary directory is the value of < the environment variable TEMP, or C:\temp by default. Under < MacOS, the name of the temporary directory is given by the < environment variable TempFolder; if not set, temporary files < are created in the current directory. < < --- > temp_file prefix suffix returns the name of a fresh temporary file in the > temporary directory. The base name of the temporary file is formed by > concatenating prefix, then a suitably chosen integer number, then suffix. > The temporary file is created empty, with permissions 0o600 (readable and > writable only by the file owner). The file is guaranteed to be different > from any other file that existed when temp_file was called. 1103,1113c987,1003 < Same as Filename.temp_file[20.8], but returns both the name of < a fresh temporary file, and an output channel opened < (atomically) on this file. This function is more secure than < temp_file: there is no risk that the temporary file will be < modified (e.g. replaced by a symbolic link) before the program < opens it. The optional argument mode is a list of additional < flags to control the opening of the file. It can contain one or < several of Open_append, Open_binary, and Open_text. The default < is [Open_text] (open in text mode). < < --- > Same as Filename.temp_file[20.8], but returns both the name of a fresh > temporary file, and an output channel opened (atomically) on this file. This > function is more secure than temp_file: there is no risk that the temporary > file will be modified (e.g. replaced by a symbolic link) before the program > opens it. The optional argument mode is a list of additional flags to > control the opening of the file. It can contain one or several of > Open_append, Open_binary, and Open_text. The default is [Open_text] (open in > text mode). > > << > val temp_dir_name : string > >> > > The name of the temporary directory: Under Unix, the value of the TMPDIR > environment variable, or "/tmp" if the variable is not set. Under Windows, > the value of the TEMP environment variable, or "." if the variable is not > set. 1119,1122c1009,1012 < Return a quoted version of a file name, suitable for use as < one argument in a shell command line, escaping all shell < meta-characters. < --- > Return a quoted version of a file name, suitable for use as one argument in > a command line, escaping all meta-characters. Warning: under Windows, the > output is only suitable for use with programs that follow the standard > Windows quoting conventions. 1131c1021 < ``pretty-printing boxes''. The pretty-printer breaks lines at specified break --- > "pretty-printing boxes". The pretty-printer breaks lines at specified break 1133,1142c1023,1030 < Warning: the material output by the following functions is delayed in the < pretty-printer queue in order to compute the proper line breaking. Hence, you < should not mix calls to the printing functions of the basic I/O system with < calls to the functions of this module: this could result in some strange < output seemingly unrelated with the evaluation order of printing commands. < You may consider this module as providing an extension to the printf < facility to provide automatic line breaking. The addition of pretty-printing < annotations to your regular printf formats gives you fancy indentation and < line breaks. Pretty-printing annotations are described below in the < documentation of the function Format.fprintf[20.9]. --- > For a gentle introduction to the basics of pretty-printing using Format, read > http://caml.inria.fr/resources/doc/guides/format.html[http://caml.inria.fr/reso > urces/doc/guides/format.html]. > You may consider this module as providing an extension to the printf facility > to provide automatic line breaking. The addition of pretty-printing annotations > to your regular printf formats gives you fancy indentation and line breaks. > Pretty-printing annotations are described below in the documentation of the > function Format.fprintf[20.9]. 1146c1034 < For instance, the sequence open_box (); print_string "x ="; print_space (); --- > For instance, the sequence open_box 0; print_string "x ="; print_space (); 1156,1161c1044,1049 < - once a box is opened, display its material with basic printing functions < (e. g. print_int and print_string); < - when the material for a box has been printed, call close_box () to close < the box; < - at the end of your routine, evaluate print_newline () to close all < remaining boxes and flush the pretty-printer. --- > - once a box is opened, display its material with basic printing functions (e. > g. print_int and print_string); > - when the material for a box has been printed, call close_box () to close the > box; > - at the end of your routine, evaluate print_newline () to close all remaining > boxes and flush the pretty-printer. 1170a1059,1064 > Warning: the material output by the following functions is delayed in the > pretty-printer queue in order to compute the proper line breaking. Hence, you > should not mix calls to the printing functions of the basic I/O system with > calls to the functions of this module: this could result in some strange output > seemingly unrelated with the evaluation order of printing commands. > 1177d1070 < 1182,1191c1075,1081 < open_box d opens a new pretty-printing box with offset d. < This box is the general purpose pretty-printing box. Material < in this box is displayed ``horizontal or vertical'': break < hints inside the box may lead to a new line, if there is no < more room on the line to print the remainder of the box, or if < a new line may lead to a new indentation (demonstrating the < indentation of the box). When a new line is printed in the box, < d is added to the current indentation. < < --- > open_box d opens a new pretty-printing box with offset d. This box is the > general purpose pretty-printing box. Material in this box is displayed > "horizontal or vertical": break hints inside the box may lead to a new line, > if there is no more room on the line to print the remainder of the box, or > if a new line may lead to a new indentation (demonstrating the indentation > of the box). When a new line is printed in the box, d is added to the > current indentation. 1204d1093 < 1211,1212d1099 < < 1217,1220c1104,1105 < print_as len str prints str in the current box. The < pretty-printer formats str as if it were of length len. < < --- > print_as len str prints str in the current box. The pretty-printer formats > str as if it were of length len. 1228,1229d1112 < < 1236,1237d1118 < < 1244,1245d1124 < < 1257d1135 < 1262,1267c1140,1143 < print_space () is used to separate items (typically to print a < space between two words). It indicates that the line may be < split at this point. It either prints one space or splits the < line. It is equivalent to print_break 1 0. < < --- > print_space () is used to separate items (typically to print a space > between two words). It indicates that the line may be split at this point. > It either prints one space or splits the line. It is equivalent to > print_break 1 0. 1273,1279c1149,1152 < print_cut () is used to mark a good break position. It < indicates that the line may be split at this point. It either < prints nothing or splits the line. This allows line splitting < at the current point, without printing spaces or adding < indentation. It is equivalent to print_break 0 0. < < --- > print_cut () is used to mark a good break position. It indicates that the > line may be split at this point. It either prints nothing or splits the > line. This allows line splitting at the current point, without printing > spaces or adding indentation. It is equivalent to print_break 0 0. 1285,1293c1158,1162 < Inserts a break hint in a pretty-printing box. print_break < nspaces offset indicates that the line may be split (a newline < character is printed) at this point, if the contents of the < current box does not fit on the current line. If the line is < split at that point, offset is added to the current < indentation. If the line is not split, nspaces spaces are < printed. < < --- > Inserts a break hint in a pretty-printing box. print_break nspaces offset > indicates that the line may be split (a newline character is printed) at > this point, if the contents of the current box does not fit on the current > line. If the line is split at that point, offset is added to the current > indentation. If the line is not split, nspaces spaces are printed. 1299,1302c1168,1169 < Flushes the pretty printer: all opened boxes are closed, and < all pending text is displayed. < < --- > Flushes the pretty printer: all opened boxes are closed, and all pending > text is displayed. 1310,1311d1176 < < 1316,1319c1181,1182 < Forces a newline in the current box. Not the normal way of < pretty-printing, you should prefer break hints. < < --- > Forces a newline in the current box. Not the normal way of pretty-printing, > you should prefer break hints. 1325,1326c1188,1189 < Executes the next formatting command if the preceding line has < just been split. Otherwise, ignore the next formatting command. --- > Executes the next formatting command if the preceding line has just been > split. Otherwise, ignore the next formatting command. 1333d1195 < 1338,1343c1200,1203 < set_margin d sets the value of the right margin to d (in < characters): this value is used to detect line overflows that < leads to split lines. Nothing happens if d is smaller than 2 or < bigger than 999999999. < < --- > set_margin d sets the value of the right margin to d (in characters): this > value is used to detect line overflows that leads to split lines. Nothing > happens if d is smaller than 2. If d is too large, the right margin is set > to the maximum admissible value (which is greater than 10^10). 1356d1215 < 1361,1367c1220,1224 < set_max_indent d sets the value of the maximum indentation < limit to d (in characters): once this limit is reached, boxes < are rejected to the left, if they do not fit on the current < line. Nothing happens if d is smaller than 2 or bigger than < 999999999. < < --- > set_max_indent d sets the value of the maximum indentation limit to d (in > characters): once this limit is reached, boxes are rejected to the left, if > they do not fit on the current line. Nothing happens if d is smaller than 2. > If d is too large, the limit is set to the maximum admissible value (which > is greater than 10^10). 1373,1374c1230 < Return the value of the maximum indentation limit (in < characters). --- > Return the value of the maximum indentation limit (in characters). 1381d1236 < 1386,1392c1241,1244 < set_max_boxes max sets the maximum number of boxes < simultaneously opened. Material inside boxes nested deeper is < printed as an ellipsis (more precisely as the text returned by < get_ellipsis_text ()). Nothing happens if max is not greater < than 1. < < --- > set_max_boxes max sets the maximum number of boxes simultaneously opened. > Material inside boxes nested deeper is printed as an ellipsis (more > precisely as the text returned by get_ellipsis_text ()). Nothing happens if > max is smaller than 2. 1400,1401d1251 < < 1406,1407c1256 < Tests if the maximum number of boxes allowed have already been < opened. --- > Tests if the maximum number of boxes allowed have already been opened. 1414d1262 < 1419,1423c1267,1269 < open_hbox () opens a new pretty-printing box. This box is < ``horizontal'': the line is not split in this box (new lines < may still occur inside boxes nested deeper). < < --- > open_hbox () opens a new pretty-printing box. This box is "horizontal": the > line is not split in this box (new lines may still occur inside boxes nested > deeper). 1429,1434c1275,1277 < open_vbox d opens a new pretty-printing box with offset d. < This box is ``vertical'': every break hint inside this box < leads to a new line. When a new line is printed in the box, d < is added to the current indentation. < < --- > open_vbox d opens a new pretty-printing box with offset d. This box is > "vertical": every break hint inside this box leads to a new line. When a new > line is printed in the box, d is added to the current indentation. 1440,1446c1283,1286 < open_hvbox d opens a new pretty-printing box with offset d. < This box is ``horizontal-vertical'': it behaves as an < ``horizontal'' box if it fits on a single line, otherwise it < behaves as a ``vertical'' box. When a new line is printed in < the box, d is added to the current indentation. < < --- > open_hvbox d opens a new pretty-printing box with offset d. This box is > "horizontal-vertical": it behaves as an "horizontal" box if it fits on a > single line, otherwise it behaves as a "vertical" box. When a new line is > printed in the box, d is added to the current indentation. 1452,1456c1292,1296 < open_hovbox d opens a new pretty-printing box with offset d. < This box is ``horizontal or vertical'': break hints inside this < box may lead to a new line, if there is no more room on the < line to print the remainder of the box. When a new line is < printed in the box, d is added to the current indentation. --- > open_hovbox d opens a new pretty-printing box with offset d. This box is > "horizontal or vertical": break hints inside this box may lead to a new > line, if there is no more room on the line to print the remainder of the > box. When a new line is printed in the box, d is added to the current > indentation. 1463d1302 < 1470,1471d1308 < < 1478,1479d1314 < < 1484,1492c1319,1324 < Break hint in a tabulation box. print_tbreak spaces offset < moves the insertion point to the next tabulation (spaces being < added to this position). Nothing occurs if insertion point is < already on a tabulation mark. If there is no next tabulation < on the line, then a newline is printed and the insertion point < moves to the first tabulation of the box. If a new line is < printed, offset is added to the current indentation. < < --- > Break hint in a tabulation box. print_tbreak spaces offset moves the > insertion point to the next tabulation (spaces being added to this > position). Nothing occurs if insertion point is already on a tabulation > mark. If there is no next tabulation on the line, then a newline is printed > and the insertion point moves to the first tabulation of the box. If a new > line is printed, offset is added to the current indentation. 1500,1501d1331 < < 1513d1342 < 1518,1521c1347,1348 < Set the text of the ellipsis printed when too many boxes are < opened (a single dot, ., by default). < < --- > Set the text of the ellipsis printed when too many boxes are opened (a > single dot, ., by default). 1534d1360 < 1544,1547c1370,1373 < ``markers'' are not considered as part of the printing material that drive < line breaking (in other words, the length of those strings is considered as < zero for line breaking). < Thus, tag handling is in some sense transparent to pretty-printing and do --- > "markers" are not considered as part of the printing material that drives line > breaking (in other words, the length of those strings is considered as zero for > line breaking). > Thus, tag handling is in some sense transparent to pretty-printing and does 1549,1569c1375,1393 < routine can output both simple ``verbatim'' material or richer decorated < output depending on the treatment of tags. Default behavior of the pretty < printer engine is to consider tags as active, so that output is decorated. < Otherwise, if set_tags is set to false, the pretty printer engine just skips < tags, and the output is regular. < When a tag has been opened (or closed), it is both and successively < ``printed'' and ``marked''. Printing a tag means calling a formatter specific < function with the name of the tag as argument: that ``tag printing'' function < can then print any regular material to the formatter (so that this material is < enqueued as usual in the formatter queue for further line-breaking < computation). Marking a tag means to output an arbitrary string (the ``tag < marker''), directly into the output device of the formatter. Hence, the < formatter specific ``tag marking'' function must return the tag marker string < associated to its tag argument. Being flushed directly into the output device < of the formatter, tag marker strings are not considered as part of the < printing material that drive line breaking (in other words, the length of the < strings corresponding to tag markers is considered as zero for line < breaking). In addition, advanced users may take advantage of the specificity < of tag markers to be precisely output when the pretty printer has already < decided where to break the lines, and precisely when the queue is flushed into < the output device. --- > routine can output both simple "verbatim" material or richer decorated output > depending on the treatment of tags. By default, tags are not active, hence the > output is not decorated with tag information. Once set_tags is set to true, the > pretty printer engine honors tags and decorates the output accordingly. > When a tag has been opened (or closed), it is both and successively "printed" > and "marked". Printing a tag means calling a formatter specific function with > the name of the tag as argument: that "tag printing" function can then print > any regular material to the formatter (so that this material is enqueued as > usual in the formatter queue for further line-breaking computation). Marking a > tag means to output an arbitrary string (the "tag marker"), directly into the > output device of the formatter. Hence, the formatter specific "tag marking" > function must return the tag marker string associated to its tag argument. > Being flushed directly into the output device of the formatter, tag marker > strings are not considered as part of the printing material that drives line > breaking (in other words, the length of the strings corresponding to tag > markers is considered as zero for line breaking). In addition, advanced users > may take advantage of the specificity of tag markers to be precisely output > when the pretty printer has already decided where to break the lines, and > precisely when the queue is flushed into the output device. 1576d1399 < 1581,1586c1404,1406 < open_tag t opens the tag named t; the print_open_tag function < of the formatter is called with t as argument; the tag marker < mark_open_tag t will be flushed into the output device of the < formatter. < < --- > open_tag t opens the tag named t; the print_open_tag function of the > formatter is called with t as argument; the tag marker mark_open_tag t will > be flushed into the output device of the formatter. 1592,1597c1412,1415 < close_tag () closes the most recently opened tag t. In < addition, the print_close_tag function of the formatter is < called with t as argument. The marker mark_close_tag t will be < flushed into the output device of the formatter. < < --- > close_tag () closes the most recently opened tag t. In addition, the > print_close_tag function of the formatter is called with t as argument. The > marker mark_close_tag t will be flushed into the output device of the > formatter. 1603,1606c1421 < set_tags b turns on or off the treatment of tags (default is < on). < < --- > set_tags b turns on or off the treatment of tags (default is off). 1612d1426 < 1617,1620c1431,1432 < set_print_tags b turns on or off the printing of tags, while < set_mark_tags b turns on or off the output of tag markers. < < --- > set_print_tags b turns on or off the printing of tags, while set_mark_tags > b turns on or off the output of tag markers. 1626d1437 < 1631c1442 < Return the current status of tag printing and marking. --- > Return the current status of tags printing and tags marking. 1638d1448 < 1645,1646d1454 < < 1652,1660c1460,1465 < set_formatter_output_functions out flush redirects the < pretty-printer output to the functions out and flush. < The out function performs the pretty-printer output. It is < called with a string s, a start position p, and a number of < characters n; it is supposed to output characters p to p + n - < 1 of s. The flush function is called whenever the < pretty-printer is flushed using print_flush or print_newline. < < --- > set_formatter_output_functions out flush redirects the pretty-printer > output to the functions out and flush. > The out function performs the pretty-printer output. It is called with a > string s, a start position p, and a number of characters n; it is supposed > to output characters p to p + n - 1 of s. The flush function is called > whenever the pretty-printer is flushed using print_flush or print_newline. 1674d1478 < 1684,1692c1488,1492 < The tag handling functions specific to a formatter: mark < versions are the ``tag marking'' functions that associate a < string marker to a tag in order for the pretty-printing engine < to flush those markers as 0 length tokens in the output device < of the formatter. print versions are the ``tag printing'' < functions that can perform regular printing when a tag is < closed or opened. < < --- > The tag handling functions specific to a formatter: mark versions are the > "tag marking" functions that associate a string marker to a tag in order for > the pretty-printing engine to flush those markers as 0 length tokens in the > output device of the formatter. print versions are the "tag printing" > functions that can perform regular printing when a tag is closed or opened. 1701,1705c1501,1505 < function (the mark_open_tag field of the record tag_funs), that must return < the opening tag marker for that name. When the next call to close_tag () < happens, the tag name t is sent back to the closing tag marking function (the < mark_close_tag field of record tag_funs), that must return a closing tag < marker for that name. --- > function (the mark_open_tag field of the record tag_funs), that must return the > opening tag marker for that name. When the next call to close_tag () happens, > the tag name t is sent back to the closing tag marking function (the > mark_close_tag field of record tag_funs), that must return a closing tag marker > for that name. 1709d1508 < 1723d1521 < 1731,1742c1529,1538 < set_all_formatter_output_functions out flush outnewline < outspace redirects the pretty-printer output to the functions < out and flush as described in set_formatter_output_functions. < In addition, the pretty-printer function that outputs a newline < is set to the function outnewline and the function that outputs < indentation spaces is set to the function outspace. < This way, you can change the meaning of indentation (which can < be something else than just printing space characters) and the < meaning of new lines opening (which can be connected to any < other action needed by the application at hand). The two < functions outspace and outnewline are normally connected to out < and flush: respective default values for outspace and --- > set_all_formatter_output_functions out flush outnewline outspace redirects > the pretty-printer output to the functions out and flush as described in > set_formatter_output_functions. In addition, the pretty-printer function > that outputs a newline is set to the function outnewline and the function > that outputs indentation spaces is set to the function outspace. > This way, you can change the meaning of indentation (which can be something > else than just printing space characters) and the meaning of new lines > opening (which can be connected to any other action needed by the > application at hand). The two functions outspace and outnewline are normally > connected to out and flush: respective default values for outspace and 1745,1746d1540 < < 1754,1755c1548,1549 < Return the current output functions of the pretty-printer, < including line breaking and indentation functions. --- > Return the current output functions of the pretty-printer, including line > breaking and indentation functions. 1762d1555 < 1767,1780c1560,1569 < Abstract data type corresponding to a pretty-printer (also < called a formatter) and all its machinery. Defining new < pretty-printers permits the output of material in parallel on < several channels. Parameters of a pretty-printer are local to < this pretty-printer: margin, maximum indentation limit, maximum < number of boxes simultaneously opened, ellipsis, and so on, are < specific to each pretty-printer and may be fixed independently. < Given an output channel oc, a new formatter writing to that < channel is obtained by calling formatter_of_out_channel oc. < Alternatively, the make_formatter function allocates a new < formatter with explicit output and flushing functions < (convenient to output material to strings for instance). < < --- > Abstract data type corresponding to a pretty-printer (also called a > formatter) and all its machinery. Defining new pretty-printers permits the > output of material in parallel on several channels. Parameters of a > pretty-printer are local to this pretty-printer: margin, maximum indentation > limit, maximum number of boxes simultaneously opened, ellipsis, and so on, > are specific to each pretty-printer and may be fixed independently. Given an > output channel oc, a new formatter writing to that channel is obtained by > calling formatter_of_out_channel oc. Alternatively, the make_formatter > function allocates a new formatter with explicit output and flushing > functions (convenient to output material to strings for instance). 1786,1789c1575,1576 < formatter_of_out_channel oc returns a new formatter that < writes to the corresponding channel oc. < < --- > formatter_of_out_channel oc returns a new formatter that writes to the > corresponding channel oc. 1795,1798c1582,1583 < The standard formatter used by the formatting functions above. < It is defined as formatter_of_out_channel stdout. < < --- > The standard formatter used by the formatting functions above. It is > defined as formatter_of_out_channel stdout. 1804,1808c1589,1590 < A formatter to use with formatting functions below for output < to standard error. It is defined as formatter_of_out_channel < stderr. < < --- > A formatter to use with formatting functions below for output to standard > error. It is defined as formatter_of_out_channel stderr. 1814,1819c1596,1598 < formatter_of_buffer b returns a new formatter writing to < buffer b. As usual, the formatter has to be flushed at the end < of pretty printing, using pp_print_flush or pp_print_newline, < to display all the pending material. < < --- > formatter_of_buffer b returns a new formatter writing to buffer b. As > usual, the formatter has to be flushed at the end of pretty printing, using > pp_print_flush or pp_print_newline, to display all the pending material. 1827,1828d1605 < < 1833,1837c1610,1611 < A formatter to use with formatting functions below for output < to the stdbuf string buffer. str_formatter is defined as < formatter_of_buffer stdbuf. < < --- > A formatter to use with formatting functions below for output to the stdbuf > string buffer. str_formatter is defined as formatter_of_buffer stdbuf. 1843,1846c1617,1618 < Returns the material printed with str_formatter, flushes the < formatter and resets the corresponding buffer. < < --- > Returns the material printed with str_formatter, flushes the formatter and > resets the corresponding buffer. 1853,1856c1625,1628 < make_formatter out flush returns a new formatter that writes < according to the output function out, and the flushing function < flush. Hence, a formatter to the out channel oc is returned by < make_formatter (output oc) (fun () -> flush oc). --- > make_formatter out flush returns a new formatter that writes according to > the output function out, and the flushing function flush. Hence, a formatter > to the out channel oc is returned by make_formatter (output oc) (fun () -> > flush oc). 1863d1634 < 1868d1638 < 1873d1642 < 1878d1646 < 1883d1650 < 1888d1654 < 1893d1658 < 1898d1662 < 1903d1666 < 1908d1670 < 1913d1674 < 1918d1678 < 1923d1682 < 1928d1686 < 1933d1690 < 1938d1694 < 1943d1698 < 1948d1702 < 1953d1706 < 1958d1710 < 1963d1714 < 1968d1718 < 1973d1722 < 1978d1726 < 1983d1730 < 1988d1734 < 1993d1738 < 1998d1742 < 2003d1746 < 2008d1750 < 2013d1754 < 2018d1758 < 2023d1762 < 2028d1766 < 2033d1770 < 2038d1774 < 2043d1778 < 2048d1782 < 2053d1786 < 2058d1790 < 2063d1794 < 2069d1799 < 2072,2073c1802 < formatter -> < (string -> int -> int -> unit) -> (unit -> unit) -> unit --- > formatter -> (string -> int -> int -> unit) -> (unit -> unit) -> unit 2076d1804 < 2082d1809 < 2091d1817 < 2100d1825 < 2106d1830 < 2112,2115c1836,1838 < These functions are the basic ones: usual functions operating < on the standard formatter are defined via partial evaluation of < these primitives. For instance, print_string is equal to < pp_print_string std_formatter. --- > These functions are the basic ones: usual functions operating on the > standard formatter are defined via partial evaluation of these primitives. > For instance, print_string is equal to pp_print_string std_formatter. 2122d1844 < 2124c1846 < val fprintf : formatter -> ('a, formatter, unit) format -> 'a --- > val fprintf : formatter -> ('a, formatter, unit) Pervasives.format -> 'a 2127,2133c1849,1854 < fprintf ff format arg1 ... argN formats the arguments arg1 to < argN according to the format string format, and outputs the < resulting string on the formatter ff. The format is a character < string which contains three types of objects: plain characters < and conversion specifications as specified in the printf < module, and pretty-printing indications. The pretty-printing < indication characters are introduced by a @ character, and --- > fprintf ff format arg1 ... argN formats the arguments arg1 to argN > according to the format string format, and outputs the resulting string on > the formatter ff. The format is a character string which contains three > types of objects: plain characters and conversion specifications as > specified in the printf module, and pretty-printing indications. The > pretty-printing indication characters are introduced by a @ character, and 2136,2140c1857,1860 < - @[: open a pretty-printing box. The type and offset of the < box may be optionally specified with the following syntax: < the < character, followed by an optional box type indication, < then an optional integer offset, and the closing > < character. Box type is one of h, v, hv, b, or hov, which --- > - @[: open a pretty-printing box. The type and offset of the box may be > optionally specified with the following syntax: the < character, followed > by an optional box type indication, then an optional integer offset, and > the closing > character. Box type is one of h, v, hv, b, or hov, which 2142,2148c1862,1867 < ``horizontal-vertical'' box, or an ``horizontal or < vertical'' box (b standing for an ``horizontal or vertical'' < box demonstrating indentation and hov standing for a < regular``horizontal or vertical'' box). For instance, @[<hov < 2> opens an ``horizontal or vertical'' box with indentation < 2 as obtained with open_hovbox 2. For more details about < boxes, see the various box opening functions open_*box. --- > "horizontal-vertical" box, or an "horizontal or vertical" box (b standing > for an "horizontal or vertical" box demonstrating indentation and hov > standing for a regular"horizontal or vertical" box). For instance, @[<hov > 2> opens an "horizontal or vertical" box with indentation 2 as obtained > with open_hovbox 2. For more details about boxes, see the various box > opening functions open_*box. 2153,2173c1872,1890 < - @;: output a good break as with print_break. The nspaces and < offset parameters of the break may be optionally specified < with the following syntax: the < character, followed by an < integer nspaces value, then an integer offset, and a closing < > character. < - @?: flush the pretty printer as with print_flush (). < - @.: flush the pretty printer and output a new line, as with < print_newline (). < - @<n>: print the following item as if it were of length n. < Hence, printf "@<0>%s" arg is equivalent to print_as 0 arg. < If @<n> is not followed by a conversion specification, then < the following character of the format is printed as if it < were of length n. < - @{: open a tag. The name of the tag may be optionally < specified with the following syntax: the < character, < followed by an optional string specification, and the < closing > character. The string specification is any < character string that does not contain the closing character < '>'. If omitted, the tag name defaults to the empty string. < For more details about tags, see the functions open_tag and < close_tag. --- > - @;: output a good break as with print_break. The nspaces and offset > parameters of the break may be optionally specified with the following > syntax: the < character, followed by an integer nspaces value, then an > integer offset, and a closing > character. If no parameters are provided, > the good break defaults to a space. > - @?: flush the pretty printer as with print_flush (). This is equivalent > to the conversion %!. > - @.: flush the pretty printer and output a new line, as with print_newline > (). > - @<n>: print the following item as if it were of length n. Hence, printf > "@<0>%s" arg is equivalent to print_as 0 arg. If @<n> is not followed by > a conversion specification, then the following character of the format is > printed as if it were of length n. > - @{: open a tag. The name of the tag may be optionally specified with the > following syntax: the < character, followed by an optional string > specification, and the closing > character. The string specification is > any character string that does not contain the closing character '>'. If > omitted, the tag name defaults to the empty string. For more details > about tags, see the functions open_tag and close_tag. 2177,2181c1894,1896 < Example: printf "@[%s@ %d@]" "x =" 1 is equivalent to open_box < (); print_string "x ="; print_space (); print_int 1; close_box < (). It prints x = 1 within a pretty-printing box. < < --- > Example: printf "@[%s@ %d@]" "x =" 1 is equivalent to open_box (); > print_string "x ="; print_space (); print_int 1; close_box (). It prints x = > 1 within a pretty-printing box. 2184c1899 < val printf : ('a, formatter, unit) format -> 'a --- > val printf : ('a, formatter, unit) Pervasives.format -> 'a 2189,2190d1903 < < 2192c1905 < val eprintf : ('a, formatter, unit) format -> 'a --- > val eprintf : ('a, formatter, unit) Pervasives.format -> 'a 2196a1910,1912 > << > val sprintf : ('a, unit, string) Pervasives.format -> 'a > >> 2197a1914,1921 > Same as printf above, but instead of printing on a formatter, returns a > string containing the result of formatting the arguments. Note that the > pretty-printer queue is flushed at the end of each call to sprintf. > In case of multiple and related calls to sprintf to output material on a > single string, you should consider using fprintf with a formatter writing to > a buffer: flushing the buffer at the end of pretty-printing returns the > desired string. You can also use the predefined formatter str_formatter and > call flush_str_formatter () to get the result. 2200c1924 < val sprintf : ('a, unit, string) format -> 'a --- > val bprintf : Buffer.t -> ('a, formatter, unit) Pervasives.format -> 'a 2203,2212c1927,1934 < Same as printf above, but instead of printing on a formatter, < returns a string containing the result of formatting the < arguments. Note that the pretty-printer queue is flushed at the < end of each call to sprintf. < In case of multiple and related calls to sprintf to output < material on a single string, you should consider using fprintf < with a formatter writing to a buffer: flushing the buffer at the < end of pretty-printing returns the desired string. You can also < use the predefined formatter str_formatter and call < flush_str_formatter () to get the result. --- > Same as sprintf above, but instead of printing on a string, writes into the > given extensible buffer. As for sprintf, the pretty-printer queue is flushed > at the end of each call to bprintf. > In case of multiple and related calls to bprintf to output material on the > same buffer b, you should consider using fprintf with a formatter writing to > the buffer b (as obtained by formatter_of_buffer b), otherwise the repeated > flushes of the pretty-printer queue would result in unexpected and badly > formatted output. 2213a1936,1940 > << > val kfprintf : > (formatter -> 'a) -> > formatter -> ('b, formatter, unit, 'a) Pervasives.format4 -> 'b > >> 2214a1942,1943 > Same as fprintf above, but instead of returning immediately, passes the > formatter to its first argument at the end of printing. 2217c1946 < val bprintf : Buffer.t -> ('a, formatter, unit) format -> 'a --- > val ifprintf : formatter -> ('a, formatter, unit) Pervasives.format -> 'a 2220,2229c1949,1950 < Same as sprintf above, but instead of printing on a string, < writes into the given extensible buffer. As for sprintf, the < pretty-printer queue is flushed at the end of each call to < bprintf. < In case of multiple and related calls to bprintf to output < material on the same buffer b, you should consider using < fprintf with a formatter writing to the buffer b (as obtained < by formatter_of_buffer b), otherwise the repeated flushes of the < pretty-printer queue would result in unexpected and badly < formatted output. --- > Same as fprintf above, but does not print anything. Useful to ignore some > material when conditionally printing. 2230a1952,1955 > << > val ksprintf : > (string -> 'a) -> ('b, unit, string, 'a) Pervasives.format4 -> 'b > >> 2231a1957,1958 > Same as sprintf above, but instead of returning the string, passes it to > the first argument. 2234c1961,1962 < val kprintf : (string -> string) -> ('a, unit, string) format -> 'a --- > val kprintf : > (string -> 'a) -> ('b, unit, string, 'a) Pervasives.format4 -> 'b 2237,2239c1965 < Same as sprintf above, but instead of returning the string, < passes it to the first argument. < --- > A deprecated synonym for ksprintf. 2249d1974 < 2255,2257c1980,1982 < Number of words allocated in the minor heap since the program < was started. This number is accurate in byte-code programs, but < only an approximation in programs compiled to native code. --- > Number of words allocated in the minor heap since the program was started. > This number is accurate in byte-code programs, but only an approximation in > programs compiled to native code. 2263,2265c1988,1989 < Number of words allocated in the minor heap that survived a < minor collection and were moved to the major heap since the < program was started. --- > Number of words allocated in the minor heap that survived a minor > collection and were moved to the major heap since the program was started. 2271,2272c1995,1996 < Number of words allocated in the major heap, including the < promoted words, since the program was started. --- > Number of words allocated in the major heap, including the promoted words, > since the program was started. 2284,2285c2008 < Number of major collection cycles completed since the program < was started. --- > Number of major collection cycles completed since the program was started. 2297,2298c2020 < Number of contiguous pieces of memory that make up the major < heap. --- > Number of contiguous pieces of memory that make up the major heap. 2304,2305c2026,2027 < Number of words of live data in the major heap, including the < header words. --- > Number of words of live data in the major heap, including the header words. > 2335,2337c2057,2058 < Number of wasted words due to fragmentation. These are 1-words < free blocks placed between two live blocks. They are not < available for allocation. --- > Number of wasted words due to fragmentation. These are 1-words free blocks > placed between two live blocks. They are not available for allocation. 2356,2361c2077,2080 < The total amount of memory allocated by the program since it was < started is (in words) minor_words + major_words - < promoted_words. Multiply by the word size (4 on a 32-bit < machine, 8 on a 64-bit machine) to get the number of bytes. < < --- > The total amount of memory allocated by the program since it was started is > (in words) minor_words + major_words - promoted_words. Multiply by the word > size (4 on a 32-bit machine, 8 on a 64-bit machine) to get the number of > bytes. 2368,2369c2087,2088 < The size (in words) of the minor heap. Changing this parameter < will trigger a minor collection. Default: 32k. --- > The size (in words) of the minor heap. Changing this parameter will trigger > a minor collection. Default: 32k. 2375,2376c2094,2095 < The minimum number of words to add to the major heap when < increasing it. Default: 62k. --- > The minimum number of words to add to the major heap when increasing it. > Default: 62k. 2382,2386c2101,2104 < The major GC speed is computed from this parameter. This is < the memory that will be "wasted" because the GC does not < immediatly collect unreachable blocks. It is expressed as a < percentage of the memory used for live data. The GC will work < more (use more CPU time and collect blocks more eagerly) if --- > The major GC speed is computed from this parameter. This is the memory that > will be "wasted" because the GC does not immediatly collect unreachable > blocks. It is expressed as a percentage of the memory used for live data. > The GC will work more (use more CPU time and collect blocks more eagerly) if 2393,2395c2111,2113 < This value controls the GC messages on standard error output. < It is a sum of some of the following flags, to print messages < on the corresponding events: --- > This value controls the GC messages on standard error output. It is a sum > of some of the following flags, to print messages on the corresponding > events: 2406,2407c2124,2125 < - 0x200 Computation of compaction triggering condition. < Default: 0. --- > - 0x200 Computation of compaction triggering condition. Default: 0. > 2413,2418c2131,2135 < Heap compaction is triggered when the estimated amount of < "wasted" memory is more than max_overhead percent of the amount < of live data. If max_overhead is set to 0, heap compaction is < triggered at the end of each major GC cycle (this setting is < intended for testing purposes only). If max_overhead >= < 1000000, compaction is never triggered. Default: 500. --- > Heap compaction is triggered when the estimated amount of "wasted" memory > is more than max_overhead percent of the amount of live data. If > max_overhead is set to 0, heap compaction is triggered at the end of each > major GC cycle (this setting is intended for testing purposes only). If > max_overhead >= 1000000, compaction is never triggered. Default: 500. 2424,2426c2141,2143 < The maximum size of the stack (in words). This is only < relevant to the byte-code runtime, as the native code runtime < uses the operating system's stack. Default: 256k. --- > The maximum size of the stack (in words). This is only relevant to the > byte-code runtime, as the native code runtime uses the operating system's > stack. Default: 256k. 2432,2434c2149,2151 < The GC parameters are given as a control record. < < --- > The GC parameters are given as a control record. Note that these parameters > can also be initialised by setting the OCAMLRUNPARAM environment variable. > See the documentation of ocamlrun. 2440,2441c2157,2158 < Return the current values of the memory management counters in < a stat record. --- > Return the current values of the memory management counters in a stat > record. This function examines every heap block to get the statistics. 2442a2160,2162 > << > val quick_stat : unit -> stat > >> 2443a2164,2166 > Same as stat except that live_words, live_blocks, free_words, free_blocks, > largest_free, and fragments are set to 0. This function is much faster than > stat because it does not need to go through the heap. 2449,2452c2172,2173 < Return (minor_words, promoted_words, major_words). Much faster < than stat. < < --- > Return (minor_words, promoted_words, major_words). This function is as fast > at quick_stat. 2458,2461c2179 < Return the current values of the GC parameters in a control < record. < < --- > Return the current values of the GC parameters in a control record. 2467,2471c2185,2186 < set r changes the GC parameters according to the control record < r. The normal usage is: Gc.set { (Gc.get()) with Gc.verbose = < 0x00d } < < --- > set r changes the GC parameters according to the control record r. The > normal usage is: Gc.set { (Gc.get()) with Gc.verbose = 0x00d } 2479,2480d2193 < < 2485,2490c2198,2200 < Do a minor collection and a slice of major collection. The < argument is the size of the slice, 0 to use the < automatically-computed slice size. In all cases, the result is < the computed slice size. < < --- > Do a minor collection and a slice of major collection. The argument is the > size of the slice, 0 to use the automatically-computed slice size. In all > cases, the result is the computed slice size. 2496,2499c2206 < Do a minor collection and finish the current major collection < cycle. < < --- > Do a minor collection and finish the current major collection cycle. 2505,2509c2212,2214 < Do a minor collection, finish the current major collection < cycle, and perform a complete new cycle. This will collect all < currently unreachable blocks. < < --- > Do a minor collection, finish the current major collection cycle, and > perform a complete new cycle. This will collect all currently unreachable > blocks. 2515,2518c2220,2221 < Perform a full major collection and compact the heap. Note that < heap compaction is a lengthy operation. < < --- > Perform a full major collection and compact the heap. Note that heap > compaction is a lengthy operation. 2527,2528d2229 < < 2533,2537c2234,2236 < Return the total number of bytes allocated since the program < was started. It is returned as a float to avoid overflow < problems with int on 32-bit machines. < < --- > Return the total number of bytes allocated since the program was started. > It is returned as a float to avoid overflow problems with int on 32-bit > machines. 2543,2557c2242,2256 < finalise f v registers f as a finalisation function for v. v < must be heap-allocated. f will be called with v as argument at < some point between the first time v becomes unreachable and the < time v is collected by the GC. Several functions can be < registered for the same value, or even several instances of the < same function. Each instance will be called once (or never, if < the program terminates before v becomes unreachable). < A number of pitfalls are associated with finalised values: < finalisation functions are called asynchronously, sometimes < even during the execution of other finalisation functions. In a < multithreaded program, finalisation functions are called from < any thread, thus they must not acquire any mutex. < Anything reachable from the closure of finalisation functions < is considered reachable, so the following code will not work as < expected: --- > finalise f v registers f as a finalisation function for v. v must be > heap-allocated. f will be called with v as argument at some point between > the first time v becomes unreachable and the time v is collected by the GC. > Several functions can be registered for the same value, or even several > instances of the same function. Each instance will be called once (or never, > if the program terminates before v becomes unreachable). > The GC will call the finalisation functions in the order of deallocation. > When several values become unreachable at the same time (i.e. during the > same GC cycle), the finalisation functions will be called in the reverse > order of the corresponding calls to finalise. If finalise is called in the > same order as the values are allocated, that means each value is finalised > before the values it depends upon. Of course, this becomes false if > additional dependencies are introduced by assignments. > Anything reachable from the closure of finalisation functions is considered > reachable, so the following code will not work as expected: 2565,2584c2264,2279 < The f function can use all features of O'Caml, including < assignments that make the value reachable again. It can also < loop forever (in this case, the other finalisation functions < will be called during the execution of f). It can call finalise < on v or other values to register other functions or even < itself. It can raise an exception; in this case the exception < will interrupt whatever the program was doing when the function < was called. < finalise will raise Invalid_argument if v is not < heap-allocated. Some examples of values that are not < heap-allocated are integers, constant constructors, booleans, < the empty array, the empty list, the unit value. The exact list < of what is heap-allocated or not is implementation-dependent. < Some constant values can be heap-allocated but never deallocated < during the lifetime of the program, for example a list of < integer constants; this is also implementation-dependent. You < should also be aware that compiler optimisations may duplicate < some immutable values, for example floating-point numbers when < stored into arrays, so they can be finalised and collected while < another copy is still in use by the program. --- > The f function can use all features of O'Caml, including assignments that > make the value reachable again. It can also loop forever (in this case, the > other finalisation functions will be called during the execution of f). It > can call finalise on v or other values to register other functions or even > itself. It can raise an exception; in this case the exception will interrupt > whatever the program was doing when the function was called. > finalise will raise Invalid_argument if v is not heap-allocated. Some > examples of values that are not heap-allocated are integers, constant > constructors, booleans, the empty array, the empty list, the unit value. The > exact list of what is heap-allocated or not is implementation-dependent. > Some constant values can be heap-allocated but never deallocated during the > lifetime of the program, for example a list of integer constants; this is > also implementation-dependent. You should also be aware that compiler > optimisations may duplicate some immutable values, for example > floating-point numbers when stored into arrays, so they can be finalised and > collected while another copy is still in use by the program. 2587,2588c2282 < heap-allocated and non-constant except when the length < argument is 0. --- > heap-allocated and non-constant except when the length argument is 0. 2589a2284,2286 > << > val finalise_release : unit -> unit > >> 2590a2288,2290 > A finalisation function may call finalise_release to tell the GC that it > can launch the next finalisation function without waiting for the current > one to return. 2596,2600c2296,2298 < An alarm is a piece of data that calls a user function at the < end of each major GC cycle. The following functions are < provided to create and delete alarms. < < --- > An alarm is a piece of data that calls a user function at the end of each > major GC cycle. The following functions are provided to create and delete > alarms. 2606,2611c2304,2306 < create_alarm f will arrange for f to be called at the end of < each major GC cycle, starting with the current cycle or the < next one. A value of type alarm is returned that you can use < to call delete_alarm. < < --- > create_alarm f will arrange for f to be called at the end of each major GC > cycle, starting with the current cycle or the next one. A value of type > alarm is returned that you can use to call delete_alarm. 2617,2619c2312,2313 < delete_alarm a will stop the calls to the function associated < to a. Calling delete_alarm a again has no effect. < --- > delete_alarm a will stop the calls to the function associated to a. Calling > delete_alarm a again has no effect. 2627,2628c2321,2322 < This module implements a simple ``standard'' lexical analyzer, presented as < a function from character streams to token streams. It implements roughly the --- > This module implements a simple "standard" lexical analyzer, presented as a > function from character streams to token streams. It implements roughly the 2636,2637c2330,2331 < The associated parser would be a function from token stream to, for < instance, int, and would have rules such as: --- > The associated parser would be a function from token stream to, for instance, > int, and would have rules such as: 2652d2345 < 2663,2672c2356,2361 < The type of tokens. The lexical classes are: Int and Float for < integer and floating-point numbers; String for string literals, < enclosed in double quotes; Char for character literals, < enclosed in single quotes; Ident for identifiers (either < sequences of letters, digits, underscores and quotes, or < sequences of ``operator characters'' such as +, *, etc); and < Kwd for keywords (either identifiers or single ``special < characters'' such as (, }, etc). < < --- > The type of tokens. The lexical classes are: Int and Float for integer and > floating-point numbers; String for string literals, enclosed in double > quotes; Char for character literals, enclosed in single quotes; Ident for > identifiers (either sequences of letters, digits, underscores and quotes, or > sequences of "operator characters" such as +, *, etc); and Kwd for keywords > (either identifiers or single "special characters" such as (, }, etc). 2678,2685c2367,2372 < Construct the lexer function. The first argument is the list of < keywords. An identifier s is returned as Kwd s if s belongs to < this list, and as Ident s otherwise. A special character s is < returned as Kwd s if s belongs to this list, and cause a < lexical error (exception Parse_error) otherwise. Blanks and < newlines are skipped. Comments delimited by (* and *) are < skipped as well, and can be nested. < --- > Construct the lexer function. The first argument is the list of keywords. > An identifier s is returned as Kwd s if s belongs to this list, and as Ident > s otherwise. A special character s is returned as Kwd s if s belongs to this > list, and cause a lexical error (exception Parse_error) otherwise. Blanks > and newlines are skipped. Comments delimited by (* and *) are skipped as > well, and can be nested. 2696a2384 > 2700d2387 < 2707,2708d2393 < < 2713,2718c2398,2401 < Hashtbl.create n creates a new, empty hash table, with initial < size n. For best results, n should be on the order of the < expected number of elements that will be in the table. The < table grows as needed, so n is just an initial guess. < < --- > Hashtbl.create n creates a new, empty hash table, with initial size n. For > best results, n should be on the order of the expected number of elements > that will be in the table. The table grows as needed, so n is just an > initial guess. 2726,2727d2408 < < 2732,2738c2413,2416 < Hashtbl.add tbl x y adds a binding of x to y in table tbl. < Previous bindings for x are not removed, but simply hidden. < That is, after performing Hashtbl.remove[20.12] tbl x, the < previous binding for x, if any, is restored. (Same behavior as < with association lists.) < < --- > Hashtbl.add tbl x y adds a binding of x to y in table tbl. Previous > bindings for x are not removed, but simply hidden. That is, after performing > Hashtbl.remove[20.12] tbl x, the previous binding for x, if any, is > restored. (Same behavior as with association lists.) 2746,2747d2423 < < 2752,2755c2428,2429 < Hashtbl.find tbl x returns the current binding of x in tbl, or < raises Not_found if no such binding exists. < < --- > Hashtbl.find tbl x returns the current binding of x in tbl, or raises > Not_found if no such binding exists. 2761,2766c2435,2437 < Hashtbl.find_all tbl x returns the list of all data associated < with x in tbl. The current binding is returned first, then the < previous bindings, in reverse order of introduction in the < table. < < --- > Hashtbl.find_all tbl x returns the list of all data associated with x in > tbl. The current binding is returned first, then the previous bindings, in > reverse order of introduction in the table. 2774,2775d2444 < < 2780,2784c2449,2450 < Hashtbl.remove tbl x removes the current binding of x in tbl, < restoring the previous binding if it exists. It does nothing if < x is not bound in tbl. < < --- > Hashtbl.remove tbl x removes the current binding of x in tbl, restoring the > previous binding if it exists. It does nothing if x is not bound in tbl. 2790,2796c2456,2459 < Hashtbl.replace tbl x y replaces the current binding of x in < tbl by a binding of x to y. If x is unbound in tbl, a binding < of x to y is added to tbl. This is functionally equivalent to < Hashtbl.remove[20.12] tbl x followed by Hashtbl.add[20.12] tbl < x y. < < --- > Hashtbl.replace tbl x y replaces the current binding of x in tbl by a > binding of x to y. If x is unbound in tbl, a binding of x to y is added to > tbl. This is functionally equivalent to Hashtbl.remove[20.12] tbl x followed > by Hashtbl.add[20.12] tbl x y. 2802,2805c2465,2470 < Hashtbl.iter f tbl applies f to all bindings in table tbl. f < receives the key as first argument, and the associated value as < second argument. The order in which the bindings are passed to < f is unspecified. Each binding is presented exactly once to f. --- > Hashtbl.iter f tbl applies f to all bindings in table tbl. f receives the > key as first argument, and the associated value as second argument. Each > binding is presented exactly once to f. The order in which the bindings are > passed to f is unspecified. However, if the table contains several bindings > for the same key, they are passed to f in reverse order of introduction, > that is, the most recent binding is passed first. 2806a2472,2474 > << > val fold : ('a -> 'b -> 'c -> 'c) -> ('a, 'b) t -> 'c -> 'c > >> 2807a2476,2481 > Hashtbl.fold f tbl init computes (f kN dN ... (f k1 d1 init)...), where k1 > ... kN are the keys of all bindings in tbl, and d1 ... dN are the associated > values. Each binding is presented exactly once to f. The order in which the > bindings are passed to f is unspecified. However, if the table contains > several bindings for the same key, they are passed to f in reverse order of > introduction, that is, the most recent binding is passed first. 2810c2484 < val fold : ('a -> 'b -> 'c -> 'c) -> ('a, 'b) t -> 'c -> 'c --- > val length : ('a, 'b) t -> int 2813,2817c2487,2489 < Hashtbl.fold f tbl init computes (f kN dN ... (f k1 d1 < init)...), where k1 ... kN are the keys of all bindings in tbl, < and d1 ... dN are the associated values. The order in which < the bindings are passed to f is unspecified. Each binding is < presented exactly once to f. --- > Hashtbl.length tbl returns the number of bindings in tbl. Multiple bindings > are counted multiply, so Hashtbl.length gives the number of times > Hashtbl.iter calls its first argument. 2825,2835c2497 < module type HashedType = sig end < >> < [20.12.1] < << < module type S = sig end < >> < [20.12.2] < << < module Make : functor (H : HashedType) -> sig end < >> < [20.12.3] --- > module type HashedType = >> 2837,2838c2499 < The polymorphic hash primitive < ============================== --- > sig 2841,2843c2502,2504 < << < val hash : 'a -> int < >> --- > << > type t > >> 2845,2847c2506 < Hashtbl.hash x associates a positive integer to any value of < any type. It is guaranteed that if x = y, then hash x = hash y. < Moreover, hash always terminates, even on cyclic structures. --- > The type of the hashtable keys. 2848a2508,2510 > << > val equal : t -> t -> bool > >> 2849a2512 > The equality predicate used to compare keys. 2851,2853c2514,2516 < << < val hash_param : int -> int -> 'a -> int < >> --- > << > val hash : t -> int > >> 2855,2866c2518,2525 < Hashtbl.hash_param n m x computes a hash value for x, with the < same properties as for hash. The two extra parameters n and m < give more precise control over hashing. Hashing performs a < depth-first, right-to-left traversal of the structure x, < stopping after n meaningful nodes were encountered, or m nodes, < meaningful or not, were encountered. Meaningful nodes are: < integers; floating-point numbers; strings; characters; < booleans; and constant constructors. Larger values of m and n < means that more nodes are taken into account to compute the < final hash value, and therefore collisions are less likely to < happen. However, hashing takes longer. The parameters m and n < govern the tradeoff between accuracy and speed. --- > A hashing function on keys. It must be such that if two keys are equal > according to equal, then they have identical hash values as computed by > hash. Examples: suitable (equal, hash) pairs for arbitrary key types > include ((=), Hashtbl.hash[20.12]) for comparing objects by structure, > ((fun x y -> compare x y = 0), Hashtbl.hash[20.12]) for comparing objects > by structure and handling Pervasives.nan[19.2] correctly, and ((==), > Hashtbl.hash[20.12]) for comparing objects by addresses (e.g. for cyclic > keys). 2867a2527 > end 2868a2529 > The input signature of the functor Hashtbl.Make[20.12]. 2869a2531,2532 > << > module type S = >> 2871,2874c2534 < 20.12.1 Module type Hashtbl.HashedType : The input signature of the functor < ============================================================================ < Hashtbl.Make[20.12.3]. < ====================== --- > sig 2876,2878d2535 < << < module type HashedType = sig < >> 2879a2537,2539 > << > type key > >> 2880a2541,2543 > << > type 'a t > >> 2881a2545,2547 > << > val create : int -> 'a t > >> 2882a2549,2551 > << > val clear : 'a t -> unit > >> 2884,2886c2553,2555 < << < type t < >> --- > << > val copy : 'a t -> 'a t > >> 2888c2557,2559 < The type of the hashtable keys. --- > << > val add : 'a t -> key -> 'a -> unit > >> 2889a2561,2563 > << > val remove : 'a t -> key -> unit > >> 2890a2565,2567 > << > val find : 'a t -> key -> 'a > >> 2892,2894c2569,2571 < << < val equal : t -> t -> bool < >> --- > << > val find_all : 'a t -> key -> 'a list > >> 2896c2573,2575 < The equality predicate used to compare keys. --- > << > val replace : 'a t -> key -> 'a -> unit > >> 2897a2577,2579 > << > val mem : 'a t -> key -> bool > >> 2898a2581,2583 > << > val iter : (key -> 'a -> unit) -> 'a t -> unit > >> 2900,2910c2585,2587 < << < val hash : t -> int < >> < < A hashing function on keys. It must be such that if two keys < are equal according to equal, then they have identical hash < values as computed by hash. Examples: suitable (equal, hash) < pairs for arbitrary key types include ((=), < Hashtbl.hash[20.12]) for comparing objects by structure, and < ((==), Hashtbl.hash[20.12]) for comparing objects by addresses < (e.g. for mutable or cyclic keys). --- > << > val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b > >> 2911a2589,2591 > << > val length : 'a t -> int > >> 2913d2592 < << 2915,2978d2593 < >> < < < 20.12.2 Module type Hashtbl.S : The output signature of the functor < ==================================================================== < Hashtbl.Make[20.12.3]. < ====================== < < << < module type S = sig < >> < < < < < < << < type key < >> < < < << < type 'a t < >> < < < << < val create : int -> 'a t < >> < < < << < val clear : 'a t -> unit < >> < < < << < val copy : 'a t -> 'a t < >> < < < << < val add : 'a t -> key -> 'a -> unit < >> < < < << < val remove : 'a t -> key -> unit < >> < < < << < val find : 'a t -> key -> 'a < >> < < < << < val find_all : 'a t -> key -> 'a list < >> < < < << < val replace : 'a t -> key -> 'a -> unit < >> 2979a2595 > The output signature of the functor Hashtbl.Make[20.12]. 2982,2983c2598 < val mem : 'a t -> key -> bool < >> --- > module Make : >> 2984a2600,2606 > functor (H : HashedType) -> S with type key = H.t > Functor building an implementation of the hashtable structure. The functor > Hashtbl.Make returns a structure containing a type key of keys and a type 'a > t of hash tables associating data of type 'a to keys of type key. The > operations perform similarly to those of the generic interface, but use the > hashing and equality functions specified in the functor argument H instead > of generic equality and hashing. 2986,2988d2607 < << < val iter : (key -> 'a -> unit) -> 'a t -> unit < >> 2991,2993c2610,2611 < << < val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b < >> --- > The polymorphic hash primitive > ============================== 2996c2614 < end --- > val hash : 'a -> int 2999,3003c2617,2619 < < 20.12.3 Module Hashtbl.Make : Functor building an implementation of the < ======================================================================== < hashtable structure. < ==================== --- > Hashtbl.hash x associates a positive integer to any value of any type. It > is guaranteed that if x = y or Pervasives.compare x y = 0, then hash x = > hash y. Moreover, hash always terminates, even on cyclic structures. 3006c2622 < module Make : sig --- > val hash_param : int -> int -> 'a -> int 3008a2625,2634 > Hashtbl.hash_param n m x computes a hash value for x, with the same > properties as for hash. The two extra parameters n and m give more precise > control over hashing. Hashing performs a depth-first, right-to-left > traversal of the structure x, stopping after n meaningful nodes were > encountered, or m nodes, meaningful or not, were encountered. Meaningful > nodes are: integers; floating-point numbers; strings; characters; booleans; > and constant constructors. Larger values of m and n means that more nodes > are taken into account to compute the final hash value, and therefore > collisions are less likely to happen. However, hashing takes longer. The > parameters m and n govern the tradeoff between accuracy and speed. 3010,3023d2635 < The functor Hashtbl.Make returns a structure containing a type key of keys < and a type 'a t of hash tables associating data of type 'a to keys of type < key. The operations perform similarly to those of the generic interface, but < use the hashing and equality functions specified in the functor argument H < instead of generic equality and hashing. < Parameters: < < - H : Hashtbl.HashedType < < < < << < end < >> 3031,3038c2643,2648 < Unlike the built-in int type, the type int32 is guaranteed to be exactly < 32-bit wide on all platforms. All arithmetic operations over int32 are taken < modulo 2^32. < Performance notice: values of type int32 occupy more memory space than < values of type int, and arithmetic operations on int32 are generally slower < than those on int. Use int32 only when the application requires exact 32-bit < arithmetic. < --- > Unlike the built-in int type, the type int32 is guaranteed to be exactly 32-bit > wide on all platforms. All arithmetic operations over int32 are taken modulo > 2^32. > Performance notice: values of type int32 occupy more memory space than values > of type int, and arithmetic operations on int32 are generally slower than those > on int. Use int32 only when the application requires exact 32-bit arithmetic. 3047,3048d2656 < < 3055,3056d2662 < < 3063,3064d2668 < < 3071,3072d2674 < < 3079,3080d2680 < < 3087,3088d2686 < < 3095,3096d2692 < < 3101,3105c2697,2699 < 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.(/)[19.2]. < < --- > 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.(/)[19.2]. 3111,3117c2705,2707 < Integer remainder. If y is not zero, the result of Int32.rem x < y satisfies the following properties: Int32.zero <= Int32.rem x < y < Int32.abs y and 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. < < --- > 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. 3125,3126d2714 < < 3133,3134d2720 < < 3141,3142d2726 < < 3149,3150d2732 < < 3157,3158d2738 < < 3165,3166d2744 < < 3173,3174d2750 < < 3181,3182d2756 < < 3189,3190d2762 < < 3195,3198c2767,2768 < Int32.shift_left x y shifts x to the left by y bits. The < result is unspecified if y < 0 or y >= 32. < < --- > Int32.shift_left x y shifts x to the left by y bits. The result is > unspecified if y < 0 or y >= 32. 3204,3209c2774,2776 < Int32.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 unspecified if y < < 0 or y >= 32. < < --- > Int32.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 unspecified if y < 0 or y >= 32. 3215,3220c2782,2784 < Int32.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 unspecified if y < < 0 or y >= 32. < < --- > Int32.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 unspecified if y < 0 or y >= 32. 3226,3229c2790 < Convert the given integer (type int) to a 32-bit integer (type < int32). < < --- > Convert the given integer (type int) to a 32-bit integer (type int32). 3235,3240c2796,2799 < Convert the given 32-bit integer (type int32) to an integer < (type int). On 32-bit platforms, the 32-bit integer is taken < modulo 2^31, i.e. the high-order bit is lost during the < conversion. On 64-bit platforms, the conversion is exact. < < --- > Convert the given 32-bit integer (type int32) to an integer (type int). On > 32-bit platforms, the 32-bit integer is taken modulo 2^31, i.e. the > high-order bit is lost during the conversion. On 64-bit platforms, the > conversion is exact. 3246,3252c2805,2808 < Convert the given floating-point number to a 32-bit integer, < discarding the fractional part (truncate towards 0). The result < of the conversion is undefined if, after truncation, the number < is outside the range [Int32.min_int[20.13], < Int32.max_int[20.13]]. < < --- > Convert the given floating-point number to a 32-bit integer, discarding the > fractional part (truncate towards 0). The result of the conversion is > undefined if, after truncation, the number is outside the range > [Int32.min_int[20.13], Int32.max_int[20.13]]. 3260,3261d2815 < < 3266,3272c2820,2824 < Convert the given string to a 32-bit integer. The string is < read in decimal (by default) or in hexadecimal, octal or binary < if the string begins with 0x, 0o or 0b respectively. Raise < Failure "int_of_string" if the given string is not a valid < representation of an integer. < < --- > Convert the given string to a 32-bit integer. The string is read in decimal > (by default) or in hexadecimal, octal or binary if the string begins with > 0x, 0o or 0b respectively. Raise Failure "int_of_string" if the given string > is not a valid representation of an integer, or if the integer represented > exceeds the range of integers representable in type int32. 3278,3281c2830 < Return the string representation of its argument, in signed < decimal. < < --- > Return the string representation of its argument, in signed decimal. 3284c2833 < val format : string -> int32 -> string --- > val bits_of_float : float -> int32 3287,3291c2836,2839 < Int32.format fmt n return the string representation of the < 32-bit integer n in the format specified by fmt. fmt is a < Printf-style format containing exactly one %d, %i, %u, %x, %X < or %o conversion specification. This function is deprecated; < use Printf.sprintf[20.24] with a %lx format instead. --- > Return the internal representation of the given float according to the IEEE > 754 floating-point "single format" bit layout. Bit 31 of the result > represents the sign of the float; bits 30 to 23 represent the (biased) > exponent; bits 22 to 0 represent the mantissa. 3292a2841,2843 > << > val float_of_bits : int32 -> float > >> 3293a2845,2847 > Return the floating-point number whose internal representation, according > to the IEEE 754 floating-point "single format" bit layout, is the given > int32. 3301,3302d2854 < < 3307,3312c2859,2862 < The comparison function for 32-bit integers, with the same < specification as Pervasives.compare[19.2]. Along with the type < t, this function compare allows the module Int32 to be passed < as argument to the functors Set.Make[20.28.3] and < Map.Make[20.18.3]. < --- > The comparison function for 32-bit integers, with the same specification as > Pervasives.compare[19.2]. Along with the type t, this function compare > allows the module Int32 to be passed as argument to the functors > Set.Make[20.28] and Map.Make[20.18]. 3321,3328c2871,2876 < Unlike the built-in int type, the type int64 is guaranteed to be exactly < 64-bit wide on all platforms. All arithmetic operations over int64 are taken < modulo 2^64 < Performance notice: values of type int64 occupy more memory space than < values of type int, and arithmetic operations on int64 are generally slower < than those on int. Use int64 only when the application requires exact 64-bit < arithmetic. < --- > Unlike the built-in int type, the type int64 is guaranteed to be exactly 64-bit > wide on all platforms. All arithmetic operations over int64 are taken modulo > 2^64 > Performance notice: values of type int64 occupy more memory space than values > of type int, and arithmetic operations on int64 are generally slower than those > on int. Use int64 only when the application requires exact 64-bit arithmetic. 3337,3338d2884 < < 3345,3346d2890 < < 3353,3354d2896 < < 3361,3362d2902 < < 3369,3370d2908 < < 3377,3378d2914 < < 3385,3386d2920 < < 3391,3395c2925,2927 < 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.(/)[19.2]. < < --- > 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.(/)[19.2]. 3401,3407c2933,2935 < Integer remainder. If y is not zero, the result of Int64.rem x < y satisfies the following properties: Int64.zero <= Int64.rem x < y < Int64.abs y and x = Int64.add (Int64.mul (Int64.div x y) y) < (Int64.rem x y). If y = 0, Int64.rem x y raises < Division_by_zero. < < --- > 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). If y = 0, Int64.rem x y raises Division_by_zero. 3415,3416d2942 < < 3423,3424d2948 < < 3431,3432d2954 < < 3439,3440d2960 < < 3447,3448d2966 < < 3455,3456d2972 < < 3463,3464d2978 < < 3471,3472d2984 < < 3479,3480d2990 < < 3485,3488c2995,2996 < Int64.shift_left x y shifts x to the left by y bits. The < result is unspecified if y < 0 or y >= 64. < < --- > Int64.shift_left x y shifts x to the left by y bits. The result is > unspecified if y < 0 or y >= 64. 3494,3499c3002,3004 < Int64.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 unspecified if y < < 0 or y >= 64. < < --- > Int64.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 unspecified if y < 0 or y >= 64. 3505,3510c3010,3012 < Int64.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 unspecified if y < < 0 or y >= 64. < < --- > Int64.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 unspecified if y < 0 or y >= 64. 3516,3519c3018 < Convert the given integer (type int) to a 64-bit integer (type < int64). < < --- > Convert the given integer (type int) to a 64-bit integer (type int64). 3525,3532c3024,3028 < Convert the given 64-bit integer (type int64) to an integer < (type int). On 64-bit platforms, the 64-bit integer is taken < modulo 2^63, i.e. the high-order bit is lost during the < conversion. On 32-bit platforms, the 64-bit integer is taken < modulo 2^31, i.e. the top 33 bits are lost during the < conversion. < < --- > Convert the given 64-bit integer (type int64) to an integer (type int). On > 64-bit platforms, the 64-bit integer is taken modulo 2^63, i.e. the > high-order bit is lost during the conversion. On 32-bit platforms, the > 64-bit integer is taken modulo 2^31, i.e. the top 33 bits are lost during > the conversion. 3538,3544c3034,3037 < Convert the given floating-point number to a 64-bit integer, < discarding the fractional part (truncate towards 0). The result < of the conversion is undefined if, after truncation, the number < is outside the range [Int64.min_int[20.14], < Int64.max_int[20.14]]. < < --- > Convert the given floating-point number to a 64-bit integer, discarding the > fractional part (truncate towards 0). The result of the conversion is > undefined if, after truncation, the number is outside the range > [Int64.min_int[20.14], Int64.max_int[20.14]]. 3552,3553d3044 < < 3558,3561c3049,3050 < Convert the given 32-bit integer (type int32) to a 64-bit < integer (type int64). < < --- > Convert the given 32-bit integer (type int32) to a 64-bit integer (type > int64). 3567,3571c3056,3058 < Convert the given 64-bit integer (type int64) to a 32-bit < integer (type int32). The 64-bit integer is taken modulo 2^32, < i.e. the top 32 bits are lost during the conversion. < < --- > Convert the given 64-bit integer (type int64) to a 32-bit integer (type > int32). The 64-bit integer is taken modulo 2^32, i.e. the top 32 bits are > lost during the conversion. 3577,3580c3064,3065 < Convert the given native integer (type nativeint) to a 64-bit < integer (type int64). < < --- > Convert the given native integer (type nativeint) to a 64-bit integer (type > int64). 3586,3590c3071,3073 < Convert the given 64-bit integer (type int64) to a native < integer. On 32-bit platforms, the 64-bit integer is taken < modulo 2^32. On 64-bit platforms, the conversion is exact. < < --- > Convert the given 64-bit integer (type int64) to a native integer. On > 32-bit platforms, the 64-bit integer is taken modulo 2^32. On 64-bit > platforms, the conversion is exact. 3596,3602c3079,3083 < Convert the given string to a 64-bit integer. The string is < read in decimal (by default) or in hexadecimal, octal or binary < if the string begins with 0x, 0o or 0b respectively. Raise < Failure "int_of_string" if the given string is not a valid < representation of an integer. < < --- > Convert the given string to a 64-bit integer. The string is read in decimal > (by default) or in hexadecimal, octal or binary if the string begins with > 0x, 0o or 0b respectively. Raise Failure "int_of_string" if the given string > is not a valid representation of an integer, or if the integer represented > exceeds the range of integers representable in type int64. 3610,3624d3090 < < < << < val format : string -> int64 -> string < >> < < Int64.format fmt n return the string representation of the < 64-bit integer n in the format specified by fmt. fmt is a < Printf[20.24]-style format containing exactly one %d, %i, %u, < %x, %X or %o conversion specification. This function is < deprecated; use Printf.sprintf[20.24] with a %Lx format < instead. < < < 3629,3635c3095,3098 < Return the internal representation of the given float according < to the IEEE 754 floating-point ``double format'' bit layout. < Bit 63 of the result represents the sign of the float; bits 62 < to 52 represent the (biased) exponent; bits 51 to 0 represent < the mantissa. < < --- > Return the internal representation of the given float according to the IEEE > 754 floating-point "double format" bit layout. Bit 63 of the result > represents the sign of the float; bits 62 to 52 represent the (biased) > exponent; bits 51 to 0 represent the mantissa. 3641,3645c3104,3106 < Return the floating-point number whose internal representation, < according to the IEEE 754 floating-point ``double format'' bit < layout, is the given int64. < < --- > Return the floating-point number whose internal representation, according > to the IEEE 754 floating-point "double format" bit layout, is the given > int64. 3653,3654d3113 < < 3659,3664c3118,3121 < The comparison function for 64-bit integers, with the same < specification as Pervasives.compare[19.2]. Along with the type < t, this function compare allows the module Int64 to be passed < as argument to the functors Set.Make[20.28.3] and < Map.Make[20.18.3]. < --- > The comparison function for 64-bit integers, with the same specification as > Pervasives.compare[19.2]. Along with the type t, this function compare > allows the module Int64 to be passed as argument to the functors > Set.Make[20.28] and Map.Make[20.18]. 3674d3130 < 3679,3694c3135,3146 < A value of type 'a Lazy.t is a deferred computation, called a < suspension, that has a result of type 'a. The special < expression syntax lazy (expr) makes a suspension of the < computation of expr, without computing expr itself yet. < "Forcing" the suspension will then compute expr and return its < result. < Note: lazy_t is the built-in type constructor used by the < compiler for the lazy keyword. You should not use it directly. < Always use Lazy.t instead. < Note: if the program is compiled with the -rectypes option, < ill-founded recursive definitions of the form let rec x = lazy x < or let rec x = lazy(lazy(...(lazy x))) are accepted by the < type-checker and lead, when forced, to ill-formed values that < trigger infinite loops in the garbage collector and other parts < of the run-time system. Without the -rectypes option, such < ill-founded recursive definitions are rejected by the --- > A value of type 'a Lazy.t is a deferred computation, called a suspension, > that has a result of type 'a. The special expression syntax lazy (expr) > makes a suspension of the computation of expr, without computing expr itself > yet. "Forcing" the suspension will then compute expr and return its result. > Note: lazy_t is the built-in type constructor used by the compiler for the > lazy keyword. You should not use it directly. Always use Lazy.t instead. > Note: if the program is compiled with the -rectypes option, ill-founded > recursive definitions of the form let rec x = lazy x or let rec x = > lazy(lazy(...(lazy x))) are accepted by the type-checker and lead, when > forced, to ill-formed values that trigger infinite loops in the garbage > collector and other parts of the run-time system. Without the -rectypes > option, such ill-founded recursive definitions are rejected by the 3697,3698d3148 < < 3703d3152 < 3708,3714c3157,3160 < force x forces the suspension x and returns its result. If x < has already been forced, Lazy.force x returns the same value < again without recomputing it. If it raised an exception, the < same exception is raised again. Raise Undefined if the forcing < of x tries to force x itself recursively. < < --- > force x forces the suspension x and returns its result. If x has already > been forced, Lazy.force x returns the same value again without recomputing > it. If it raised an exception, the same exception is raised again. Raise > Undefined if the forcing of x tries to force x itself recursively. 3720,3727c3166,3170 < force_val x forces the suspension x and returns its result. If < x has already been forced, force_val x returns the same value < again without recomputing it. Raise Undefined if the forcing of < x tries to force x itself recursively. If the computation of x < raises an exception, it is unspecified whether force_val x < raises the same exception or Undefined. < < --- > force_val x forces the suspension x and returns its result. If x has > already been forced, force_val x returns the same value again without > recomputing it. Raise Undefined if the forcing of x tries to force x itself > recursively. If the computation of x raises an exception, it is unspecified > whether force_val x raises the same exception or Undefined. 3733,3736c3176 < lazy_from_fun f is the same as lazy (f ()) but slightly more < efficient. < < --- > lazy_from_fun f is the same as lazy (f ()) but slightly more efficient. 3742,3746c3182,3183 < lazy_from_val v returns an already-forced suspension of v This < is for special purposes only and should not be confused with < lazy (v). < < --- > lazy_from_val v returns an already-forced suspension of v This is for > special purposes only and should not be confused with lazy (v). 3752,3754c3189,3190 < lazy_is_val x returns true if x has already been forced and < did not raise an exception. < --- > lazy_is_val x returns true if x has already been forced and did not raise > an exception. 3765,3766d3200 < Lexer buffers < ============= 3767a3202,3203 > Positions > ========= 3770,3779c3206,3210 < type lexbuf = { < refill_buff : lexbuf -> unit ; < mutable lex_buffer : string ; < mutable lex_buffer_len : int ; < mutable lex_abs_pos : int ; < mutable lex_start_pos : int ; < mutable lex_curr_pos : int ; < mutable lex_last_pos : int ; < mutable lex_last_action : int ; < mutable lex_eof_reached : bool ; --- > type position = { > pos_fname : string ; > pos_lnum : int ; > pos_bol : int ; > pos_cnum : int ; 3783,3786c3214,3220 < The type of lexer buffers. A lexer buffer is the argument < passed to the scanning functions defined by the generated < scanners. The lexer buffer holds the current state of the < scanner, plus a function to refill the buffer from the input. --- > A value of type position describes a point in a source file. pos_fname is > the file name; pos_lnum is the line number; pos_bol is the offset of the > beginning of the line (number of characters between the beginning of the > file and the beginning of the line); pos_cnum is the offset of the position > (number of characters between the beginning of the file and the position). > See the documentation of type lexbuf for information about how the lexing > engine will manage positions. 3787a3222,3227 > << > val dummy_pos : position > >> > > A value of type position, guaranteed to be different from any valid > position. 3789a3230,3233 > > Lexer buffers > ============= > 3791c3235,3248 < val from_channel : Pervasives.in_channel -> lexbuf --- > type lexbuf = { > refill_buff : lexbuf -> unit ; > mutable lex_buffer : string ; > mutable lex_buffer_len : int ; > mutable lex_abs_pos : int ; > mutable lex_start_pos : int ; > mutable lex_curr_pos : int ; > mutable lex_last_pos : int ; > mutable lex_last_action : int ; > mutable lex_eof_reached : bool ; > mutable lex_mem : int array ; > mutable lex_start_p : position ; > mutable lex_curr_p : position ; > } 3794,3796c3251,3260 < Create a lexer buffer on the given input channel. < Lexing.from_channel inchan returns a lexer buffer which reads < from the input channel inchan, at the current reading position. --- > The type of lexer buffers. A lexer buffer is the argument passed to the > scanning functions defined by the generated scanners. The lexer buffer holds > the current state of the scanner, plus a function to refill the buffer from > the input. > Note that the lexing engine will only change the pos_cnum field of > lex_curr_p by updating it with the number of characters read since the start > of the lexbuf. The other fields are copied without change by the lexing > engine. In order to keep them accurate, they must be initialised before the > first use of the lexbuf, and updated by the relevant lexer actions (i.e. at > each end of line). 3797a3262,3264 > << > val from_channel : Pervasives.in_channel -> lexbuf > >> 3798a3266,3268 > Create a lexer buffer on the given input channel. Lexing.from_channel > inchan returns a lexer buffer which reads from the input channel inchan, at > the current reading position. 3804,3809c3274,3276 < Create a lexer buffer which reads from the given string. < Reading starts from the first character in the string. An < end-of-input condition is generated when the end of the string < is reached. < < --- > Create a lexer buffer which reads from the given string. Reading starts > from the first character in the string. An end-of-input condition is > generated when the end of the string is reached. 3815,3820c3282,3286 < Create a lexer buffer with the given function as its reading < method. When the scanner needs more characters, it will call < the given function, giving it a character string s and a < character count n. The function should put n characters or less < in s, starting at character number 0, and return the number of < characters provided. A return value of 0 means end of input. --- > Create a lexer buffer with the given function as its reading method. When > the scanner needs more characters, it will call the given function, giving > it a character string s and a character count n. The function should put n > characters or less in s, starting at character number 0, and return the > number of characters provided. A return value of 0 means end of input. 3828,3833c3294,3298 < definitions (the ML code enclosed in braces that computes the value returned < by lexing functions). They give access to the character string matched by the < regular expression associated with the semantic action. These functions must < be applied to the argument lexbuf, which, in the code generated by ocamllex, < is bound to the lexer buffer passed to the parsing function. < --- > definitions (the ML code enclosed in braces that computes the value returned by > lexing functions). They give access to the character string matched by the > regular expression associated with the semantic action. These functions must be > applied to the argument lexbuf, which, in the code generated by ocamllex, is > bound to the lexer buffer passed to the parsing function. 3838,3841c3303 < Lexing.lexeme lexbuf returns the string matched by the regular < expression. < < --- > Lexing.lexeme lexbuf returns the string matched by the regular expression. 3847,3848c3309,3310 < Lexing.lexeme_char lexbuf i returns character number i in the < matched string. --- > Lexing.lexeme_char lexbuf i returns character number i in the matched > string. 3849a3312,3314 > << > val lexeme_start : lexbuf -> int > >> 3850a3316,3318 > Lexing.lexeme_start lexbuf returns the offset in the input stream of the > first character of the matched string. The first character of the stream has > offset 0. 3853c3321 < val lexeme_start : lexbuf -> int --- > val lexeme_end : lexbuf -> int 3856,3858c3324,3326 < Lexing.lexeme_start lexbuf returns the position in the input < stream of the first character of the matched string. The first < character of the stream has position 0. --- > Lexing.lexeme_end lexbuf returns the offset in the input stream of the > character following the last character of the matched string. The first > character of the stream has offset 0. 3859a3328,3330 > << > val lexeme_start_p : lexbuf -> position > >> 3860a3332 > Like lexeme_start, but return a complete position instead of an offset. 3863c3335 < val lexeme_end : lexbuf -> int --- > val lexeme_end_p : lexbuf -> position 3866,3869c3338,3343 < Lexing.lexeme_end lexbuf returns the position in the input < stream of the character following the last character of the < matched string. The first character of the stream has position < 0. --- > Like lexeme_end, but return a complete position instead of an offset. > > > > Miscellaneous functions > ======================= 3870a3345,3350 > << > val flush_input : lexbuf -> unit > >> > > Discard the contents of the buffer and reset the current position to 0. The > next use of the lexbuf will trigger a refill. 3879,3883c3359,3363 < uses constant stack space, while a non-tail-recursive function uses stack < space proportional to the length of its list argument, which can be a problem < with very long lists. When the function takes several list arguments, an < approximate formula giving stack usage (in some unspecified constant unit) is < shown in parentheses. --- > uses constant stack space, while a non-tail-recursive function uses stack space > proportional to the length of its list argument, which can be a problem with > very long lists. When the function takes several list arguments, an approximate > formula giving stack usage (in some unspecified constant unit) is shown in > parentheses. 3888d3367 < 3895,3896d3373 < < 3901,3904c3378,3379 < Return the first element of the given list. Raise Failure "hd" < if the list is empty. < < --- > Return the first element of the given list. Raise Failure "hd" if the list > is empty. 3910,3913c3385,3386 < Return the given list without its first element. Raise Failure < "tl" if the list is empty. < < --- > Return the given list without its first element. Raise Failure "tl" if the > list is empty. 3919,3923c3392,3394 < 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. < < --- > 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. Raise > Invalid_argument "List.nth" if n is negative. 3931,3932d3401 < < 3938,3941c3407,3408 < tail-recursive (length of the first argument). The @ operator < is not tail-recursive either. < < --- > tail-recursive (length of the first argument). The @ operator is not > tail-recursive either. 3947,3951c3414,3416 < List.rev_append l1 l2 reverses l1 and concatenates it to l2. < This is equivalent to List.rev[20.17] l1 @ l2, but rev_append is < tail-recursive and more efficient. < < --- > List.rev_append l1 l2 reverses l1 and concatenates it to l2. This is > equivalent to List.rev[20.17] l1 @ l2, but rev_append is tail-recursive and > more efficient. 3957,3962c3422,3424 < 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). < < --- > 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). 3968,3969c3430,3431 < Same as concat. 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). 3976d3437 < 3981,3985c3442,3443 < List.iter f [a1; ...; an] applies function f in turn to a1; < ...; an. It is equivalent to begin f a1; f a2; ...; f an; () < end. < < --- > List.iter f [a1; ...; an] applies function f in turn to a1; ...; an. It is > equivalent to begin f a1; f a2; ...; f an; () end. 3991,3995c3449,3450 < List.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. < < --- > List.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. 4001,4005c3456,3457 < List.rev_map f l gives the same result as List.rev[20.17] < (List.map[20.17] f l), but is tail-recursive and more < efficient. < < --- > List.rev_map f l gives the same result as List.rev[20.17] (List.map[20.17] > f l), but is tail-recursive and more efficient. 4011,4014c3463 < List.fold_left f a [b1; ...; bn] is f (... (f (f a b1) b2) < ...) bn. < < --- > List.fold_left f a [b1; ...; bn] is f (... (f (f a b1) b2) ...) bn. 4020,4021c3469,3470 < List.fold_right f [a1; ...; an] b is f a1 (f a2 (... (f an b) < ...)). Not tail-recursive. --- > List.fold_right f [a1; ...; an] b is f a1 (f a2 (... (f an b) ...)). Not > tail-recursive. 4028d3476 < 4033,4037c3481,3482 < List.iter2 f [a1; ...; an] [b1; ...; bn] calls in turn f a1 < b1; ...; f an bn. Raise Invalid_argument if the two lists have < different lengths. < < --- > List.iter2 f [a1; ...; an] [b1; ...; bn] calls in turn f a1 b1; ...; f an > bn. Raise Invalid_argument if the two lists have different lengths. 4043,4047c3488,3490 < List.map2 f [a1; ...; an] [b1; ...; bn] is [f a1 b1; ...; f an < bn]. Raise Invalid_argument if the two lists have different < lengths. Not tail-recursive. < < --- > List.map2 f [a1; ...; an] [b1; ...; bn] is [f a1 b1; ...; f an bn]. Raise > Invalid_argument if the two lists have different lengths. Not > tail-recursive. 4053,4057c3496,3497 < List.rev_map2 f l gives the same result as List.rev[20.17] < (List.map2[20.17] f l), but is tail-recursive and more < efficient. < < --- > List.rev_map2 f l1 l2 gives the same result as List.rev[20.17] > (List.map2[20.17] f l1 l2), but is tail-recursive and more efficient. 4063,4067c3503,3505 < List.fold_left2 f a [b1; ...; bn] [c1; ...; cn] is f (... (f < (f a b1 c1) b2 c2) ...) bn cn. Raise Invalid_argument if the < two lists have different lengths. < < --- > List.fold_left2 f a [b1; ...; bn] [c1; ...; cn] is f (... (f (f a b1 c1) b2 > c2) ...) bn cn. Raise Invalid_argument if the two lists have different > lengths. 4073,4075c3511,3513 < List.fold_right2 f [a1; ...; an] [b1; ...; bn] c is f a1 b1 (f < a2 b2 (... (f an bn c) ...)). Raise Invalid_argument if the two < lists have different lengths. Not tail-recursive. --- > List.fold_right2 f [a1; ...; an] [b1; ...; bn] c is f a1 b1 (f a2 b2 (... > (f an bn c) ...)). Raise Invalid_argument if the two lists have different > lengths. Not tail-recursive. 4082d3519 < 4087,4091c3524,3525 < for_all p [a1; ...; an] checks if all elements of the list < satisfy the predicate p. That is, it returns (p a1) && (p a2) < && ... && (p an). < < --- > for_all p [a1; ...; an] checks if all elements of the list satisfy the > predicate p. That is, it returns (p a1) && (p a2) && ... && (p an). 4097,4101c3531,3532 < exists p [a1; ...; an] checks if at least one element of the < list satisfies the predicate p. That is, it returns (p a1) || < (p a2) || ... || (p an). < < --- > exists p [a1; ...; an] checks if at least one element of the list satisfies > the predicate p. That is, it returns (p a1) || (p a2) || ... || (p an). 4107,4110c3538,3539 < Same as List.for_all[20.17], but for a two-argument predicate. < Raise Invalid_argument if the two lists have different lengths. < < --- > Same as List.for_all[20.17], but for a two-argument predicate. Raise > Invalid_argument if the two lists have different lengths. 4116,4119c3545,3546 < Same as List.exists[20.17], but for a two-argument predicate. < Raise Invalid_argument if the two lists have different lengths. < < --- > Same as List.exists[20.17], but for a two-argument predicate. Raise > Invalid_argument if the two lists have different lengths. 4127,4128d3553 < < 4133,4134c3558,3559 < Same as List.mem[20.17], but uses physical equality instead of < structural equality to compare list elements. --- > Same as List.mem[20.17], but uses physical equality instead of structural > equality to compare list elements. 4141d3565 < 4146,4150c3570,3572 < 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. < < --- > 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. 4156,4160c3578,3579 < filter p l returns all the elements of the list l that satisfy < the predicate p. The order of the elements in the input list is < preserved. < < --- > filter p l returns all the elements of the list l that satisfy the > predicate p. The order of the elements in the input list is preserved. 4168,4169d3586 < < 4174,4177c3591,3594 < partition p l returns a pair of lists (l1, l2), where l1 is < the list of all the elements of l that satisfy the predicate p, < and l2 is the list of all the elements of l that do not satisfy < p. The order of the elements in the input list is preserved. --- > partition p l returns a pair of lists (l1, l2), where l1 is the list of all > the elements of l that satisfy the predicate p, and l2 is the list of all > the elements of l that do not satisfy p. The order of the elements in the > input list is preserved. 4184d3600 < 4189,4194c3605,3608 < 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. Raise Not_found if < there is no value associated with a in the list l. < < --- > 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. Raise Not_found if there is no value associated with a in the > list l. 4200,4203c3614,3615 < Same as List.assoc[20.17], but uses physical equality instead < of structural equality to compare keys. < < --- > Same as List.assoc[20.17], but uses physical equality instead of structural > equality to compare keys. 4209,4212c3621,3622 < Same as List.assoc[20.17], but simply return true if a binding < exists, and false if no bindings exist for the given key. < < --- > Same as List.assoc[20.17], but simply return true if a binding exists, and > false if no bindings exist for the given key. 4218,4221c3628,3629 < Same as List.mem_assoc[20.17], but uses physical equality < instead of structural equality to compare keys. < < --- > Same as List.mem_assoc[20.17], but uses physical equality instead of > structural equality to compare keys. 4227,4230c3635,3636 < remove_assoc a l returns the list of pairs l without the first < pair with key a, if any. Not tail-recursive. < < --- > remove_assoc a l returns the list of pairs l without the first pair with > key a, if any. Not tail-recursive. 4236,4238c3642,3643 < Same as List.remove_assoc[20.17], but uses physical equality < instead of structural equality to compare keys. Not < tail-recursive. --- > Same as List.remove_assoc[20.17], but uses physical equality instead of > structural equality to compare keys. Not tail-recursive. 4245d3649 < 4250,4254c3654,3655 < 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 list of pairs into a pair of lists: split [(a1,b1); ...; > (an,bn)] is ([a1; ...; an], [b1; ...; bn]). Not tail-recursive. 4260,4263c3661,3663 < Transform a pair of lists into a list of pairs: combine [a1; < ...; an] [b1; ...; bn] is [(a1,b1); ...; (an,bn)]. Raise < Invalid_argument if the two lists have different lengths. Not < tail-recursive. --- > Transform a pair of lists into a list of pairs: combine [a1; ...; an] [b1; > ...; bn] is [(a1,b1); ...; (an,bn)]. Raise Invalid_argument if the two lists > have different lengths. Not tail-recursive. 4270d3669 < 4275,4287c3674,3683 < Sort a list in increasing order according to a comparison < function. The comparison function must return 0 if it 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, < Pervasives.compare[19.2] is a suitable comparison function. The < resulting list is sorted in increasing order. List.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. < < --- > 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, > Pervasives.compare[19.2] is a suitable comparison function. The resulting > list is sorted in increasing order. List.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. 4293,4299c3689,3692 < Same as List.sort[20.17], 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 List.sort[20.17], 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. 4305,4308c3698,3699 < Same as List.sort[20.17] or List.stable_sort[20.17], whichever < is faster on typical input. < < --- > Same as List.sort[20.17] or List.stable_sort[20.17], whichever is faster on > typical input. 4314,4320c3705,3709 < 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 containting 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 < lenghts of the arguments). < --- > 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 > containting 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). 4336,4358c3725 < module type OrderedType = sig end < >> < [20.18.1] < << < module type S = sig end < >> < [20.18.2] < << < module Make : functor (Ord : OrderedType) -> sig end < >> < [20.18.3] < < < 20.18.1 Module type Map.OrderedType : Input signature of the functor < ===================================================================== < Map.Make[20.18.3]. < ================== < < << < module type OrderedType = sig < >> < < --- > module type OrderedType = >> 4359a3727 > sig 4362c3730 < << --- > << 4364c3732 < >> --- > >> 4368,4370c3736 < < < << --- > << 4372c3738 < >> --- > >> 4374,4379c3740,3744 < A total ordering function over the keys. This is a < two-argument function f such that f e1 e2 is zero if the keys < e1 and e2 are equal, f e1 e2 is strictly negative if e1 is < smaller than e2, and f e1 e2 is strictly positive if e1 is < greater than e2. Example: a suitable ordering function is the < generic structural comparison function Pervasives.compare[19.2]. --- > A total ordering function over the keys. This is a two-argument function > f such that f e1 e2 is zero if the keys e1 and e2 are equal, f e1 e2 is > strictly negative if e1 is smaller than e2, and f e1 e2 is strictly > positive if e1 is greater than e2. Example: a suitable ordering function > is the generic structural comparison function Pervasives.compare[19.2]. 4381,4382d3745 < < << 4384,4385d3746 < >> < 4387,4388c3748 < 20.18.2 Module type Map.S : Output signature of the functor Map.Make[20.18.3]. < =============================================================================== --- > Input signature of the functor Map.Make[20.18]. 4391,4393c3751 < module type S = sig < >> < --- > module type S = >> 4394a3753 > sig 4397,4398c3756 < < << --- > << 4400c3758 < >> --- > >> 4404,4408c3762,3764 < < < << < type 'a t < >> --- > << > type +'a t > >> 4412,4414c3768 < < < << --- > << 4416c3770 < >> --- > >> 4419a3774,3776 > << > val is_empty : 'a t -> bool > >> 4420a3778 > Test whether a map is empty or not. 4422c3780 < << --- > << 4424,4428c3782 < >> < < add x y m returns a map containing the same bindings as m, < plus a binding of x to y. If x was already bound in m, its < previous binding disappears. --- > >> 4429a3784,3786 > add x y m returns a map containing the same bindings as m, plus a > binding of x to y. If x was already bound in m, its previous binding > disappears. 4431,4432c3788 < < << --- > << 4434,4438c3790 < >> < < find x m returns the current binding of x in m, or raises < Not_found if no such binding exists. < --- > >> 4439a3792,3793 > find x m returns the current binding of x in m, or raises Not_found if > no such binding exists. 4441c3795 < << --- > << 4443c3797 < >> --- > >> 4445,4446c3799,3800 < remove x m returns a map containing the same bindings as m, < except for x which is unbound in the returned map. --- > remove x m returns a map containing the same bindings as m, except for x > which is unbound in the returned map. 4448,4450c3802 < < < << --- > << 4452,4455c3804 < >> < < mem x m returns true if m contains a binding for x, and false < otherwise. --- > >> 4456a3806 > mem x m returns true if m contains a binding for x, and false otherwise. 4458,4459c3808 < < << --- > << 4461c3810 < >> --- > >> 4463,4466c3812,3815 < iter f m applies f to all bindings in map m. f receives the < key as first argument, and the associated value as second < argument. The order in which the bindings are passed to f is < unspecified. Only current bindings are presented to f: bindings --- > iter f m applies f to all bindings in map m. f receives the key as first > argument, and the associated value as second argument. The bindings are > passed to f in increasing order with respect to the ordering over the > type of the keys. Only current bindings are presented to f: bindings 4469,4471c3818 < < < << --- > << 4473,4478c3820 < >> < < map f m returns a map with same domain as m, where the < associated value a of all bindings of m has been replaced by < the result of the application of f to a. The order in which the < associated values are passed to f is unspecified. --- > >> 4479a3822,3825 > map f m returns a map with same domain as m, where the associated value > a of all bindings of m has been replaced by the result of the application > of f to a. The bindings are passed to f in increasing order with respect > to the ordering over the type of the keys. 4481,4482c3827 < < << --- > << 4484,4488c3829 < >> < < Same as Map.S.map[20.18.2], but the function receives as < arguments both the key and the associated value for each < binding of the map. --- > >> 4489a3831,3832 > Same as Map.S.map[20.18], but the function receives as arguments both > the key and the associated value for each binding of the map. 4491,4492c3834 < < << --- > << 4494,4499c3836 < >> < < fold f m a computes (f kN dN ... (f k1 d1 a)...), where k1 ... < kN are the keys of all bindings in m, and d1 ... dN are the < associated data. The order in which the bindings are presented < to f is unspecified. --- > >> 4500a3838,3855 > fold f m a computes (f kN dN ... (f k1 d1 a)...), where k1 ... kN are > the keys of all bindings in m (in increasing order), and d1 ... dN are > the associated data. > > << > val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int > >> > > Total ordering between maps. The first argument is a total ordering used > to compare data associated with equal keys in the two maps. > > << > val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool > >> > > equal cmp m1 m2 tests whether the maps m1 and m2 are equal, that is, > contain equal keys and associate them with equal data. cmp is the > equality predicate used to compare the data associated with the keys. 4502d3856 < << 4504d3857 < >> 4506,4510c3859 < < 20.18.3 Module Map.Make : Functor building an implementation of the map < ======================================================================== < structure given a totally ordered type. < ======================================== --- > Output signature of the functor Map.Make[20.18]. 4513,4515c3862 < module Make : sig < >> < --- > module Make : >> 4517c3864,3866 < Parameters: --- > functor (Ord : OrderedType) -> S with type key = Ord.t > Functor building an implementation of the map structure given a totally > ordered type. 4519,4525d3867 < - Ord : Map.OrderedType < < < < << < end < >> 4538,4545c3880,3887 < Warning: marshaling is currently not type-safe. The type of marshaled data < is not transmitted along the value of the data, making it impossible to check < that the data read back possesses the type expected by the context. In < particular, the result type of the Marshal.from_* functions is given as 'a, < but this is misleading: the returned Caml value does not possess type 'a for < all 'a; it has one, unique type which cannot be determined at compile-type. < The programmer should explicitly give the expected type of the returned value, < using the following syntax: --- > Warning: marshaling is currently not type-safe. The type of marshaled data is > not transmitted along the value of the data, making it impossible to check that > the data read back possesses the type expected by the context. In particular, > the result type of the Marshal.from_* functions is given as 'a, but this is > misleading: the returned Caml value does not possess type 'a for all 'a; it has > one, unique type which cannot be determined at compile-type. The programmer > should explicitly give the expected type of the returned value, using the > following syntax: 4551,4556c3893,3897 < that are not printable characters. Therefore, input and output channels used < in conjunction with Marshal.to_channel and Marshal.from_channel must be opened < in binary mode, using e.g. open_out_bin or open_in_bin; channels opened in < text mode will cause unmarshaling errors on platforms where text channels < behave differently than binary channels, e.g. Windows. < --- > that are not printable characters. Therefore, input and output channels used in > conjunction with Marshal.to_channel and Marshal.from_channel must be opened in > binary mode, using e.g. open_out_bin or open_in_bin; channels opened in text > mode will cause unmarshaling errors on platforms where text channels behave > differently than binary channels, e.g. Windows. 4574,4575d3914 < < 4577,4578c3916 < val to_channel : < Pervasives.out_channel -> 'a -> extern_flags list -> unit --- > val to_channel : Pervasives.out_channel -> 'a -> extern_flags list -> unit 4581,4606c3919,3939 < Marshal.to_channel chan v flags writes the representation of v < on channel chan. The flags argument is a possibly empty list of < flags that governs the marshaling behavior with respect to < sharing and functional values. < If flags does not contain Marshal.No_sharing, circularities < and sharing inside the value v are detected and preserved in < the sequence of bytes produced. In particular, this guarantees < that marshaling always terminates. Sharing between values < marshaled by successive calls to Marshal.to_channel is not < detected, though. If flags contains Marshal.No_sharing, sharing < is ignored. This results in faster marshaling if v contains no < shared substructures, but may cause slower marshaling and < larger byte representations if v actually contains sharing, or < even non-termination if v contains cycles. < If flags does not contain Marshal.Closures, marshaling fails < when it encounters a functional value inside v: only ``pure'' < data structures, containing neither functions nor objects, can < safely be transmitted between different programs. If flags < contains Marshal.Closures, functional values will be marshaled < as a position in the code of the program. In this case, the < output of marshaling can only be read back in processes that < run exactly the same program, with exactly the same compiled < code. (This is checked at un-marshaling time, using an MD5 < digest of the code transmitted along with the code position.) < < --- > Marshal.to_channel chan v flags writes the representation of v on channel > chan. The flags argument is a possibly empty list of flags that governs the > marshaling behavior with respect to sharing and functional values. > If flags does not contain Marshal.No_sharing, circularities and sharing > inside the value v are detected and preserved in the sequence of bytes > produced. In particular, this guarantees that marshaling always terminates. > Sharing between values marshaled by successive calls to Marshal.to_channel > is not detected, though. If flags contains Marshal.No_sharing, sharing is > ignored. This results in faster marshaling if v contains no shared > substructures, but may cause slower marshaling and larger byte > representations if v actually contains sharing, or even non-termination if v > contains cycles. > If flags does not contain Marshal.Closures, marshaling fails when it > encounters a functional value inside v: only "pure" data structures, > containing neither functions nor objects, can safely be transmitted between > different programs. If flags contains Marshal.Closures, functional values > will be marshaled as a position in the code of the program. In this case, > the output of marshaling can only be read back in processes that run exactly > the same program, with exactly the same compiled code. (This is checked at > un-marshaling time, using an MD5 digest of the code transmitted along with > the code position.) 4612,4616c3945,3947 < Marshal.to_string v flags returns a string containing the < representation of v as a sequence of bytes. The flags argument < has the same meaning as for Marshal.to_channel[20.19]. < < --- > Marshal.to_string v flags returns a string containing the representation of > v as a sequence of bytes. The flags argument has the same meaning as for > Marshal.to_channel[20.19]. 4619,4620c3950 < val to_buffer : < string -> int -> int -> 'a -> extern_flags list -> int --- > val to_buffer : string -> int -> int -> 'a -> extern_flags list -> int 4623,4630c3953,3957 < Marshal.to_buffer buff ofs len v flags marshals the value v, < storing its byte representation in the string buff, starting at < character number ofs, and writing at most len characters. It < returns the number of characters actually written to the < string. If the byte representation of v does not fit in len < characters, the exception Failure is raised. < < --- > Marshal.to_buffer buff ofs len v flags marshals the value v, storing its > byte representation in the string buff, starting at character number ofs, > and writing at most len characters. It returns the number of characters > actually written to the string. If the byte representation of v does not fit > in len characters, the exception Failure is raised. 4636,4641c3963,3965 < Marshal.from_channel chan reads from channel chan the byte < representation of a structured value, as produced by one of the < Marshal.to_* functions, and reconstructs and returns the < corresponding value. < < --- > Marshal.from_channel chan reads from channel chan the byte representation > of a structured value, as produced by one of the Marshal.to_* functions, and > reconstructs and returns the corresponding value. 4647,4652c3971,3974 < Marshal.from_string buff ofs unmarshals a structured value < like Marshal.from_channel[20.19] does, except that the byte < representation is not read from a channel, but taken from the < string buff, starting at position ofs. < < --- > Marshal.from_string buff ofs unmarshals a structured value like > Marshal.from_channel[20.19] does, except that the byte representation is not > read from a channel, but taken from the string buff, starting at position > ofs. 4658,4677c3980,3994 < The bytes representing a marshaled value are composed of a < fixed-size header and a variable-sized data part, whose size < can be determined from the header. Marshal.header_size[20.19] < is the size, in characters, of the header. < Marshal.data_size[20.19] buff ofs is the size, in characters, < of the data part, assuming a valid header is stored in buff < starting at position ofs. Finally, Marshal.total_size[20.19] < buff ofs is the total size, in characters, of the marshaled < value. Both Marshal.data_size[20.19] and < Marshal.total_size[20.19] raise Failure if buff, ofs does not < contain a valid header. < To read the byte representation of a marshaled value into a < string buffer, the program needs to read first < Marshal.header_size[20.19] characters into the buffer, then < determine the length of the remainder of the representation < using Marshal.data_size[20.19], make sure the buffer is large < enough to hold the remaining data, then read it, and finally < call Marshal.from_string[20.19] to unmarshal the value. < < --- > The bytes representing a marshaled value are composed of a fixed-size > header and a variable-sized data part, whose size can be determined from the > header. Marshal.header_size[20.19] is the size, in characters, of the > header. Marshal.data_size[20.19] buff ofs is the size, in characters, of the > data part, assuming a valid header is stored in buff starting at position > ofs. Finally, Marshal.total_size[20.19] buff ofs is the total size, in > characters, of the marshaled value. Both Marshal.data_size[20.19] and > Marshal.total_size[20.19] raise Failure if buff, ofs does not contain a > valid header. > To read the byte representation of a marshaled value into a string buffer, > the program needs to read first Marshal.header_size[20.19] characters into > the buffer, then determine the length of the remainder of the representation > using Marshal.data_size[20.19], make sure the buffer is large enough to hold > the remaining data, then read it, and finally call > Marshal.from_string[20.19] to unmarshal the value. 4685,4686d4001 < < 4695d4009 < 4701,4704c4015,4018 < integers (on 32-bit platforms) or signed 64-bit integers (on 64-bit < platforms). This integer type has exactly the same width as that of a long < integer type in the C compiler. All arithmetic operations over nativeint are < taken modulo 2^32 or 2^64 depending on the word size of the architecture. --- > integers (on 32-bit platforms) or signed 64-bit integers (on 64-bit platforms). > This integer type has exactly the same width as that of a long integer type in > the C compiler. All arithmetic operations over nativeint are taken modulo 2^32 > or 2^64 depending on the word size of the architecture. 4706,4709c4020,4022 < values of type int, and arithmetic operations on nativeint are generally < slower than those on int. Use nativeint only when the application requires the < extra bit of precision over the int type. < --- > values of type int, and arithmetic operations on nativeint are generally slower > than those on int. Use nativeint only when the application requires the extra > bit of precision over the int type. 4718,4719d4030 < < 4726,4727d4036 < < 4734,4735d4042 < < 4742,4743d4048 < < 4750,4751d4054 < < 4758,4759d4060 < < 4766,4767d4066 < < 4772,4776c4071,4073 < 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.(/)[19.2]. < < --- > 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.(/)[19.2]. 4782,4789c4079,4082 < 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. < < --- > 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. 4797,4798d4089 < < 4803,4806c4094 < Predecessor. Nativeint.pred x is Nativeint.sub x < Nativeint.one. < < --- > Predecessor. Nativeint.pred x is Nativeint.sub x Nativeint.one. 4814,4815d4101 < < 4820,4823c4106,4107 < 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. < < --- > 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. 4829,4832c4113,4114 < The greatest representable native integer, either 2^31 - 1 on < a 32-bit platform, or 2^63 - 1 on a 64-bit platform. < < --- > The greatest representable native integer, either 2^31 - 1 on a 32-bit > platform, or 2^63 - 1 on a 64-bit platform. 4838,4841c4120,4121 < The greatest representable native integer, either -2^31 on a < 32-bit platform, or -2^63 on a 64-bit platform. < < --- > The greatest representable native integer, either -2^31 on a 32-bit > platform, or -2^63 on a 64-bit platform. 4849,4850d4128 < < 4857,4858d4134 < < 4865,4866d4140 < < 4873,4874d4146 < < 4879,4883c4151,4153 < 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-bit platform and 64 on a 64-bit platform. < < --- > 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-bit > platform and 64 on a 64-bit platform. 4889,4894c4159,4161 < Nativeint.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 unspecified if < y < 0 or y >= bitsize. < < --- > Nativeint.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 unspecified if y < 0 or y >= bitsize. 4900,4905c4167,4169 < Nativeint.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 < unspecified if y < 0 or y >= bitsize. < < --- > Nativeint.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 unspecified if y < 0 or y >= bitsize. 4911,4914c4175 < Convert the given integer (type int) to a native integer (type < nativeint). < < --- > Convert the given integer (type int) to a native integer (type nativeint). 4920,4924c4181,4182 < Convert the given native integer (type nativeint) to an < integer (type int). The high-order bit is lost during the < conversion. < < --- > Convert the given native integer (type nativeint) to an integer (type int). > The high-order bit is lost during the conversion. 4930,4936c4188,4191 < Convert the given floating-point number to a native integer, < discarding the fractional part (truncate towards 0). The result < of the conversion is undefined if, after truncation, the number < is outside the range [Nativeint.min_int[20.20], < Nativeint.max_int[20.20]]. < < --- > Convert the given floating-point number to a native integer, discarding the > fractional part (truncate towards 0). The result of the conversion is > undefined if, after truncation, the number is outside the range > [Nativeint.min_int[20.20], Nativeint.max_int[20.20]]. 4944,4945d4198 < < 4950,4953c4203 < Convert the given 32-bit integer (type int32) to a native < integer. < < --- > Convert the given 32-bit integer (type int32) to a native integer. 4959,4964c4209,4211 < Convert the given native integer to a 32-bit integer (type < int32). On 64-bit platforms, the 64-bit native integer is taken < modulo 2^32, i.e. the top 32 bits are lost. On 32-bit < platforms, the conversion is exact. < < --- > Convert the given native integer to a 32-bit integer (type int32). On > 64-bit platforms, the 64-bit native integer is taken modulo 2^32, i.e. the > top 32 bits are lost. On 32-bit platforms, the conversion is exact. 4970,4976c4217,4221 < Convert the given string to a native integer. The string is < read in decimal (by default) or in hexadecimal, octal or binary < if the string begins with 0x, 0o or 0b respectively. Raise < Failure "int_of_string" if the given string is not a valid < representation of an integer. < < --- > Convert the given string to a native integer. The string is read in decimal > (by default) or in hexadecimal, octal or binary if the string begins with > 0x, 0o or 0b respectively. Raise Failure "int_of_string" if the given string > is not a valid representation of an integer, or if the integer represented > exceeds the range of integers representable in type nativeint. 4984,4997d4228 < < < << < val format : string -> nativeint -> string < >> < < Nativeint.format fmt n return the string representation of the < native integer n in the format specified by fmt. fmt is a < Printf-style format containing exactly one %d, %i, %u, %x, %X < or %o conversion specification. This function is deprecated; < use Printf.sprintf[20.24] with a %nx format instead. < < < 5004,5005d4234 < < 5010,5015c4239,4242 < The comparison function for native integers, with the same < specification as Pervasives.compare[19.2]. Along with the type < t, this function compare allows the module Nativeint to be < passed as argument to the functors Set.Make[20.28.3] and < Map.Make[20.18.3]. < --- > The comparison function for native integers, with the same specification as > Pervasives.compare[19.2]. Along with the type t, this function compare > allows the module Nativeint to be passed as argument to the functors > Set.Make[20.28] and Map.Make[20.18]. 5025d4251 < 5030,5033c4256,4257 < Oo.copy o returns a copy of object o, that is a fresh object < with the same methods and instance variables as o < < --- > Oo.copy o returns a copy of object o, that is a fresh object with the same > methods and instance variables as o 5036c4260 < val id : (< .. > as 'a) -> int --- > val id : < .. > -> int 5039,5041c4263,4264 < Return an integer identifying this object, unique for the < current execution of the program. < --- > Return an integer identifying this object, unique for the current execution > of the program. 5053d4275 < 5058,5066c4280,4284 < symbol_start and Parsing.symbol_end[20.22] are to be called in < the action part of a grammar rule only. They return the < position of the string that matches the left-hand side of the < rule: symbol_start() returns the position of the first < character; symbol_end() returns the position of the last < character, plus one. The first character in a file is at < position 0. < < --- > symbol_start and Parsing.symbol_end[20.22] are to be called in the action > part of a grammar rule only. They return the offset of the string that > matches the left-hand side of the rule: symbol_start() returns the offset of > the first character; symbol_end() returns the offset after the last > character. The first character in a file is at offset 0. 5073a4292,4294 > << > val rhs_start : int -> int > >> 5074a4296,4299 > Same as Parsing.symbol_start[20.22] and Parsing.symbol_end[20.22], but > return the offset of the string matching the nth item on the right-hand side > of the rule, where n is the integer parameter to rhs_start and rhs_end. n is > 1 for the leftmost item. 5077c4302 < val rhs_start : int -> int --- > val rhs_end : int -> int 5080,5084c4305 < Same as Parsing.symbol_start[20.22] and < Parsing.symbol_end[20.22], but return the position of the < string matching the nth item on the right-hand side of the < rule, where n is the integer parameter to lhs_start and < lhs_end. n is 1 for the leftmost item. --- > See Parsing.rhs_start[20.22]. 5085a4307,4309 > << > val symbol_start_pos : unit -> Lexing.position > >> 5086a4311 > Same as symbol_start, but return a position instead of an offset. 5089c4314 < val rhs_end : int -> int --- > val symbol_end_pos : unit -> Lexing.position 5092c4317 < See Parsing.rhs_start[20.22]. --- > Same as symbol_end, but return a position instead of an offset. 5093a4319,4321 > << > val rhs_start_pos : int -> Lexing.position > >> 5094a4323 > Same as rhs_start, but return a position instead of an offset. 5097c4326 < val clear_parser : unit -> unit --- > val rhs_end_pos : int -> Lexing.position 5100,5104c4329 < Empty the parser stack. Call it just after a parsing function < has returned, to remove all pointers from the parser stack to < structures that were built by semantic actions during parsing. < This is optional, but lowers the memory requirements of the < programs. --- > Same as rhs_end, but return a position instead of an offset. 5105a4331,4333 > << > val clear_parser : unit -> unit > >> 5106a4335,4338 > Empty the parser stack. Call it just after a parsing function has returned, > to remove all pointers from the parser stack to structures that were built > by semantic actions during parsing. This is optional, but lowers the memory > requirements of the programs. 5112,5115c4344,4345 < Raised when a parser encounters a syntax error. Can also be < raised from the action part of a grammar rule, to initiate < error recovery. < --- > Raised when a parser encounters a syntax error. Can also be raised from the > action part of a grammar rule, to initiate error recovery. 5125d4354 < 5130,5133c4359 < Printexc.to_string e returns a string representation of the < exception e. < < --- > Printexc.to_string e returns a string representation of the exception e. 5139,5145c4365,4369 < Printexc.print fn x applies fn to x and returns the result. If < the evaluation of fn x raises any exception, the name of the < exception is printed on standard error output, and the < exception is raised again. The typical use is to catch and < report exceptions that escape a function application. < < --- > Printexc.print fn x applies fn to x and returns the result. If the > evaluation of fn x raises any exception, the name of the exception is > printed on standard error output, and the exception is raised again. The > typical use is to catch and report exceptions that escape a function > application. 5151,5159c4375,4381 < Printexc.catch fn x is similar to Printexc.print[20.23], but < aborts the program with exit code 2 after printing the uncaught < exception. This function is deprecated: the runtime system is < now able to print uncaught exceptions as precisely as < Printexc.catch does. Moreover, calling Printexc.catch makes it < harder to track the location of the exception using the < debugger or the stack backtrace facility. So, do not use < Printexc.catch in new code. < --- > Printexc.catch fn x is similar to Printexc.print[20.23], but aborts the > program with exit code 2 after printing the uncaught exception. This > function is deprecated: the runtime system is now able to print uncaught > exceptions as precisely as Printexc.catch does. Moreover, calling > Printexc.catch makes it harder to track the location of the exception using > the debugger or the stack backtrace facility. So, do not use Printexc.catch > in new code. 5169d4390 < 5172c4393,4394 < Pervasives.out_channel -> ('a, Pervasives.out_channel, unit) format -> 'a --- > Pervasives.out_channel -> > ('a, Pervasives.out_channel, unit) Pervasives.format -> 'a 5175,5185c4397,4407 < fprintf outchan format arg1 ... argN formats the arguments < arg1 to argN according to the format string format, and outputs < the resulting string on the channel outchan. < The format is a character string which contains two types of < objects: plain characters, which are simply copied to the < output channel, and conversion specifications, each of which < causes conversion and printing of one argument. < Conversion specifications consist in the % character, followed < by optional flags and field widths, followed by one or two < conversion character. The conversion characters and their < meanings are: --- > fprintf outchan format arg1 ... argN formats the arguments arg1 to argN > according to the format string format, and outputs the resulting string on > the channel outchan. > The format is a character string which contains two types of objects: plain > characters, which are simply copied to the output channel, and conversion > specifications, each of which causes conversion and printing of arguments. > Conversion specifications have the following form: > % [positional specifier] [flags] [width] [.precision] type > In short, a conversion specification consists in the % character, followed > by optional modifiers and a type which is made of one or two characters. The > types and their meanings are: 5187c4409,4410 < - d or i: convert an integer argument to signed decimal. --- > > - d, i, n, l, L, or N: convert an integer argument to signed decimal. 5189,5192c4412,4415 < - x: convert an integer argument to unsigned hexadecimal, < using lowercase letters. < - X: convert an integer argument to unsigned hexadecimal, < using uppercase letters. --- > - x: convert an integer argument to unsigned hexadecimal, using lowercase > letters. > - X: convert an integer argument to unsigned hexadecimal, using uppercase > letters. 5195,5196c4418 < - S: insert a string argument in Caml syntax (double quotes, < escapes). --- > - S: insert a string argument in Caml syntax (double quotes, escapes). 5198,5218c4420,4441 < - C: insert a character argument in Caml syntax (single quotes, < escapes). < - f: convert a floating-point argument to decimal notation, in < the style dddd.ddd. < - e or E: convert a floating-point argument to decimal < notation, in the style d.ddd e+-dd (mantissa and exponent). < - g or G: convert a floating-point argument to decimal < notation, in style f or e, E (whichever is more compact). < - b: convert a boolean argument to the string true or false < - ld, li, lu, lx, lX, lo: convert an int32 argument to the < format specified by the second letter (decimal, hexadecimal, < etc). < - nd, ni, nu, nx, nX, no: convert a nativeint argument to the < format specified by the second letter. < - Ld, Li, Lu, Lx, LX, Lo: convert an int64 argument to the < format specified by the second letter. < - a: user-defined printer. Takes two arguments and apply the < first one to outchan (the current output channel) and to the < second argument. The first argument must therefore have type < out_channel -> 'b -> unit and the second 'b. The output < produced by the function is therefore inserted in the output --- > - C: insert a character argument in Caml syntax (single quotes, escapes). > - f: convert a floating-point argument to decimal notation, in the style > dddd.ddd. > - F: convert a floating-point argument to Caml syntax (dddd. or dddd.ddd or > d.ddd e+-dd). > - e or E: convert a floating-point argument to decimal notation, in the > style d.ddd e+-dd (mantissa and exponent). > - g or G: convert a floating-point argument to decimal notation, in style f > or e, E (whichever is more compact). > - B: convert a boolean argument to the string true or false > - b: convert a boolean argument (for backward compatibility; do not use in > new programs). > - ld, li, lu, lx, lX, lo: convert an int32 argument to the format specified > by the second letter (decimal, hexadecimal, etc). > - nd, ni, nu, nx, nX, no: convert a nativeint argument to the format > specified by the second letter. > - Ld, Li, Lu, Lx, LX, Lo: convert an int64 argument to the format specified > by the second letter. > - a: user-defined printer. Takes two arguments and applies the first one to > outchan (the current output channel) and to the second argument. The > first argument must therefore have type out_channel -> 'b -> unit and the > second 'b. The output produced by the function is inserted in the output 5220,5221c4443,4450 < - t: same as %a, but takes only one argument (with type < out_channel -> unit) and apply it to outchan. --- > - t: same as %a, but takes only one argument (with type out_channel -> > unit) and apply it to outchan. > - { fmt %}: convert a format string argument. The argument must have the > same type as the internal format string fmt. > - ( fmt %): format string substitution. Takes a format string argument and > substitutes it to the internal format string fmt to print following > arguments. The argument must have the same type as fmt. > - !: take no argument and flush the output. 5224c4453,4456 < The optional flags include: --- > The optional positional specifier consists of an integer followed by a $; > the integer indicates which argument to use, the first argument being > denoted by 1. > The optional flags are: 5227,5251c4459,4461 < - 0: for numerical conversions, pad with zeroes instead of < spaces. < - +: for numerical conversions, prefix number with a + sign if < positive. < - space: for numerical conversions, prefix number with a space < if positive. < - `#': request an alternate formatting style for numbers. < < The field widths are composed of an optional integer literal < indicating the minimal width of the result, possibly followed by < a dot . and another integer literal indicating how many digits < follow the decimal point in the %f, %e, and %E conversions. For < instance, %6d prints an integer, prefixing it with spaces to < fill at least 6 characters; and %.4f prints a float with 4 < fractional digits. Each or both of the integer literals can also < be specified as a *, in which case an extra integer argument is < taken to specify the corresponding width or precision. < Warning: if too few arguments are provided, for instance < because the printf function is partially applied, the format is < immediately printed up to the conversion of the first missing < argument; printing will then resume when the missing arguments < are provided. For example, List.iter (printf "x=%d y=%d " 1) < [2;3] prints x=1 y=2 3 instead of the expected x=1 y=2 x=1 < y=3. To get the expected behavior, do List.iter (fun y -> < printf "x=%d y=%d " 1 y) [2;3]. --- > - 0: for numerical conversions, pad with zeroes instead of spaces. > - +: for numerical conversions, prefix number with a + sign if positive. > - space: for numerical conversions, prefix number with a space if positive. 5252a4463 > - `#': request an alternate formatting style for numbers. 5253a4465,4476 > The optional width is an integer indicating the minimal width of the result. > For instance, %6d prints an integer, prefixing it with spaces to fill at > least 6 characters. > The optional precision is a dot . followed by an integer indicating how many > digits follow the decimal point in the %f, %e, and %E conversions. For > instance, %.4f prints a float with 4 fractional digits. > The integer in a width or precision can also be specified as *, in which > case an extra integer argument is taken to specify the corresponding width > or precision. This integer argument precedes immediately the argument to > print, unless an optional positional specifier is given to indicates which > argument to use. For instance, %.*3$f prints a float with as many fractional > digits as the value of the third argument. 5256c4479 < val printf : ('a, Pervasives.out_channel, unit) format -> 'a --- > val printf : ('a, Pervasives.out_channel, unit) Pervasives.format -> 'a 5261,5262d4483 < < 5264c4485 < val eprintf : ('a, Pervasives.out_channel, unit) format -> 'a --- > val eprintf : ('a, Pervasives.out_channel, unit) Pervasives.format -> 'a 5268a4490,4492 > << > val ifprintf : 'a -> ('b, 'a, unit) Pervasives.format -> 'b > >> 5269a4494,4495 > Same as Printf.fprintf[20.24], but does not print anything. Useful to > ignore some material when conditionally printing. 5272c4498 < val sprintf : ('a, unit, string) format -> 'a --- > val sprintf : ('a, unit, string) Pervasives.format -> 'a 5275,5277c4501,4502 < Same as Printf.fprintf[20.24], but instead of printing on an < output channel, return a string containing the result of < formatting the arguments. --- > Same as Printf.fprintf[20.24], but instead of printing on an output > channel, return a string containing the result of formatting the arguments. 5278a4504,4506 > << > val bprintf : Buffer.t -> ('a, Buffer.t, unit) Pervasives.format -> 'a > >> 5279a4508,4510 > Same as Printf.fprintf[20.24], but instead of printing on an output > channel, append the formatted arguments to the given extensible buffer (see > module Buffer[20.3]). 5282c4513,4516 < val bprintf : Buffer.t -> ('a, Buffer.t, unit) format -> 'a --- > val kfprintf : > (Pervasives.out_channel -> 'a) -> > Pervasives.out_channel -> > ('b, Pervasives.out_channel, unit, 'a) Pervasives.format4 -> 'b 5285,5287c4519,4521 < Same as Printf.fprintf[20.24], but instead of printing on an < output channel, append the formatted arguments to the given < extensible buffer (see module Buffer[20.3]). --- > Formatted output functions with continuations. > Same as fprintf, but instead of returning immediately, passes the out > channel to its first argument at the end of printing. 5288a4523,4526 > << > val ksprintf : > (string -> 'a) -> ('b, unit, string, 'a) Pervasives.format4 -> 'b > >> 5289a4528,4529 > Same as sprintf above, but instead of returning the string, passes it to > the first argument. 5292c4532,4534 < val kprintf : (string -> string) -> ('a, unit, string) format -> 'a --- > val kbprintf : > (Buffer.t -> 'a) -> > Buffer.t -> ('b, Buffer.t, unit, 'a) Pervasives.format4 -> 'b 5295,5298c4537,4543 < kprintf k format arguments is the same as sprintf format < arguments, except that the resulting string is passed as < argument to k; the result of k is then returned as the result < of kprintf. --- > Same as bprintf, but instead of returning immediately, passes the buffer to > its first argument at the end of printing. > > << > val kprintf : > (string -> 'a) -> ('b, unit, string, 'a) Pervasives.format4 -> 'b > >> 5299a4545 > A deprecated synonym for ksprintf. 5310d4555 < 5317,5318d4561 < < 5323,5326c4566,4567 < Raised when Queue.take[20.25] or Queue.peek[20.25] is applied < to an empty queue. < < --- > Raised when Queue.take[20.25] or Queue.peek[20.25] is applied to an empty > queue. 5334,5335d4574 < < 5342,5343d4580 < < 5350,5351d4586 < < 5356,5359c4591,4592 < take q removes and returns the first element in queue q, or < raises Empty if the queue is empty. < < --- > take q removes and returns the first element in queue q, or raises Empty if > the queue is empty. 5367,5368d4599 < < 5373,5376c4604,4605 < peek q returns the first element in queue q, without removing < it from the queue, or raises Empty if the queue is empty. < < --- > peek q returns the first element in queue q, without removing it from the > queue, or raises Empty if the queue is empty. 5384,5385d4612 < < 5392,5393d4618 < < 5400,5401d4624 < < 5408,5409d4630 < < 5416,5417d4636 < < 5422,5426c4641,4642 < iter f q applies f in turn to all elements of q, from the < least recently entered to the most recently entered. The queue < itself is unchanged. < < --- > iter f q applies f in turn to all elements of q, from the least recently > entered to the most recently entered. The queue itself is unchanged. 5432,5435c4648,4649 < fold f accu q is equivalent to List.fold_left f accu l, where < l is the list of q's elements. The queue remains unchanged. < < --- > fold f accu q is equivalent to List.fold_left f accu l, where l is the list > of q's elements. The queue remains unchanged. 5441,5443c4655,4657 < transfer q1 q2 adds all of q1's elements at the end of the < queue q2, then clears q1. It is equivalent to the sequence iter < (fun x -> add x q2) q1; clear q1, but runs in constant time. --- > transfer q1 q2 adds all of q1's elements at the end of the queue q2, then > clears q1. It is equivalent to the sequence iter (fun x -> add x q2) q1; > clear q1, but runs in constant time. 5446a4661,4662 > 20.26 Module Random : Pseudo-random number generators (PRNG). > *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= 5448,5449d4663 < 20.26 Module Random : Pseudo-random number generator (PRNG). < *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* 5454a4669,4671 > Basic functions > =============== > 5459,5462c4676,4677 < Initialize the generator, using the argument as a seed. The < same seed will always yield the same sequence of numbers. < < --- > Initialize the generator, using the argument as a seed. The same seed will > always yield the same sequence of numbers. 5470,5471d4684 < < 5476,5479c4689,4690 < Initialize the generator with a more-or-less random seed chosen < in a system-dependent way. < < --- > Initialize the generator with a more-or-less random seed chosen in a > system-dependent way. 5487,5488d4697 < < 5493,5497c4702,4703 < Random.int bound returns a random integer between 0 (inclusive) < and bound (exclusive). bound must be more than 0 and less than < 2^30. < < --- > Random.int bound returns a random integer between 0 (inclusive) and bound > (exclusive). bound must be greater than 0 and less than 2^30. 5500c4706 < val float : float -> float --- > val int32 : Int32.t -> Int32.t 5503,5508c4709,4710 < Random.float bound returns a random floating-point number < between 0 (inclusive) and bound (exclusive). If bound is < negative, the result is negative. If bound is 0, the result is < 0. < < --- > Random.int32 bound returns a random integer between 0 (inclusive) and bound > (exclusive). bound must be greater than 0. 5511c4713 < val bool : unit -> bool --- > val nativeint : Nativeint.t -> Nativeint.t 5514,5516c4716,4717 < Random.bool () returns true or false with probability 0.5 each. < < --- > Random.nativeint bound returns a random integer between 0 (inclusive) and > bound (exclusive). bound must be greater than 0. 5519c4720 < type state --- > val int64 : Int64.t -> Int64.t 5522,5525c4723,4724 < Values of this type are used to store the current state of the < generator. < < --- > Random.int64 bound returns a random integer between 0 (inclusive) and bound > (exclusive). bound must be greater than 0. 5528c4727 < val get_state : unit -> state --- > val float : float -> float 5531,5534c4730,4732 < Returns the current state of the generator. This is useful for < checkpointing computations that use the PRNG. < < --- > Random.float bound returns a random floating-point number between 0 > (inclusive) and bound (exclusive). If bound is negative, the result is > negative or zero. If bound is 0, the result is 0. 5537c4735 < val set_state : state -> unit --- > val bool : unit -> bool 5540,5541c4738 < Resets the state of the generator to some previous state < returned by Random.get_state[20.26]. --- > Random.bool () returns true or false with probability 0.5 each. 5544a4742,4743 > Advanced functions > ================== 5546,5547c4745,4750 < 20.27 Module Scanf : Formatted input functions. < *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= --- > The functions from module State manipulate the current state of the random > generator explicitely. This allows using one or several deterministic PRNGs, > even in a multi-threaded program, without interference from other parts of the > program. > << > module State : >> 5548a4752 > sig 5550a4755,4757 > << > type t > >> 5552,5555c4759 < << < module Scanning : sig end < >> < [20.27.1] --- > The type of PRNG states. 5557,5559c4761,4763 < << < exception Scan_failure of string < >> --- > << > val make : int array -> t > >> 5561,5562c4765 < The exception that formatted input functions raise when the < input cannot be read according to the given format. --- > Create a new state and initialize it with the given seed. 5563a4767,4769 > << > val make_self_init : unit -> t > >> 5564a4771,4772 > Create a new state and initialize it with a system-dependent low-entropy > seed. 5566,5570c4774,4776 < << < val bscanf : < Scanning.scanbuf -> < ('a, Scanning.scanbuf, 'b) format -> 'a -> 'b < >> --- > << > val copy : t -> t > >> 5572,5588c4778 < bscanf ib format f reads tokens from the scanning buffer ib < according to the format string format, converts these tokens to < values, and applies the function f to these values. The result < of this application of f is the result of the whole construct. < Raise Scanf.Scan_failure if the given input does not match the < format. < Raise Failure if a conversion to a number is not possible. < Raise End_of_file if the end of input is encountered while < scanning and the input matches the given format so far. < The format is a character string which contains three types of < objects: < < - plain characters, which are simply matched with the < characters of the input, < - conversion specifications, each of which causes reading and < conversion of one argument for f, < - scanning indications to specify boundaries of tokens. --- > Return a copy of the given state. 5590,5597c4780,4782 < Among plain characters the space character (ASCII code 32) has a < special meaning: it matches ``whitespace'', that is any number < of tab, space, newline and carriage return characters. Hence, a < space in the format matches any amount of whitespace in the < input. < Conversion specifications consist in the % character, followed < by optional field width, followed by one or two conversion < characters. The conversion characters and their meanings are: --- > << > val bits : t -> int > >> 5599,5629c4784,4786 < - d: reads an optionally signed decimal integer. < - i: reads an optionally signed integer (usual input formats < for hexadecimal (0x[d]+ and 0X[d]+), octal (0o[d]+), and < binary 0b[d]+ notations are understood). < - u: reads an unsigned decimal integer. < - x or X: reads an unsigned hexadecimal integer. < - o: reads an unsigned octal integer. < - s: reads a string argument (by default strings end with a < space). < - S: reads a delimited string argument (delimiters and special < escaped characters follow the lexical conventions of Caml). < - c: reads a single character. < - C: reads a single delimited character (delimiters and special < escaped characters follow the lexical conventions of Caml). < - f, e, E, g, G: reads an optionally signed floating-point < number in decimal notation, in the style dddd.ddd e/E+-dd. < - b: reads a boolean argument (true or false). < - ld, li, lu, lx, lX, lo: reads an int32 argument to the < format specified by the second letter (decimal, hexadecimal, < etc). < - nd, ni, nu, nx, nX, no: reads a nativeint argument to the < format specified by the second letter. < - Ld, Li, Lu, Lx, LX, Lo: reads an int64 argument to the < format specified by the second letter. < - [ range ]: reads characters that matches one of the < characters mentioned in the range of characters range (or < not mentioned in it, if the range starts with ^). Returns a < string that can be empty, if no character in the input < matches the range. < - N: applies f to the number of characters read so far. < - %: matches one % character in the input. --- > << > val int : t -> int -> int > >> 5631,5648c4788,4790 < The field widths are composed of an optional integer literal < indicating the maximal width of the token to read. For < instance, %6d reads an integer, having at most 6 decimal digits; < and %4f reads a float with 4 characters. < Scanning indications appear just after string conversions s and < [ range ] to delimit the end of the token. A scanning < indication is introduced by a @ character, followed by some < constant character c. It means that the string token should end < just before the next matching c. If no c character is < encountered, the string token spreads as much as possible. For < instance, "%s@\t" reads a string up to the next tabulation < character. If a scanning indication @c does not follow a string < conversion, it is ignored and treated as a plain c character. < Note: the scanf facility is not intended for heavy duty lexical < analysis and parsing. If it appears not expressive enough for < your needs, several alternative exists: regular expressions < (module Str), stream parsers, ocamllex-generated lexers, < ocamlyacc-generated parsers. --- > << > val int32 : t -> Int32.t -> Int32.t > >> 5649a4792,4794 > << > val nativeint : t -> Nativeint.t -> Nativeint.t > >> 5650a4796,4798 > << > val int64 : t -> Int64.t -> Int64.t > >> 5652,5656c4800,4802 < << < val fscanf : < Pervasives.in_channel -> < ('a, Scanning.scanbuf, 'b) format -> 'a -> 'b < >> --- > << > val float : t -> float -> float > >> 5658c4804,4806 < Same as Scanf.bscanf[20.27], but inputs from the given channel. --- > << > val bool : t -> bool > >> 5659a4808,4809 > These functions are the same as the basic functions, except that they > use (and update) the given PRNG state instead of the default one. 5660a4811 > end 5663c4814 < val sscanf : string -> ('a, Scanning.scanbuf, 'b) format -> 'a -> 'b --- > val get_state : unit -> State.t 5666,5668c4817 < Same as Scanf.bscanf[20.27], but inputs from the given string. < < --- > Return the current state of the generator used by the basic functions. 5671c4820 < val scanf : ('a, Scanning.scanbuf, 'b) format -> 'a -> 'b --- > val set_state : State.t -> unit 5674,5675c4823 < Same as Scanf.bscanf[20.27], but inputs from stdin (the < standard input channel). --- > Set the state of the generator used by the basic functions. 5679,5684c4827,4829 < << < val kscanf : < Scanning.scanbuf -> < (Scanning.scanbuf -> exn -> 'a) -> < ('b, Scanning.scanbuf, 'a) format -> 'b -> 'a < >> --- > 20.27 Module Scanf : Formatted input functions. > *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= > 5686,5690d4830 < Same as Scanf.bscanf[20.27], but takes an additional function < argument ef that is called in case of error: if the scanning < process or some conversion fails, the scanning function aborts < and applies the error handling function ef to the scanning < buffer and the exception that aborted evaluation. 5695,5696c4835,4836 < 20.27.1 Module Scanf.Scanning : Scanning buffers. < ================================================== --- > Functional input with format strings. > ===================================== 5697a4838,4863 > The formatted input functions provided by module Scanf are functionals that > apply their function argument to the values they read in the input. The > specification of the values to read is simply given by a format string (the > same format strings as those used to print material using module Printf[20.24] > or module Format[20.9]). > As an example, consider the formatted input function scanf that reads from > standard input; a typical call to scanf is simply scanf fmt f, meaning that f > should be applied to the arguments read according to the format string fmt. For > instance, if f is defined as let f x = x + 1, then scanf "%d" f will read a > decimal integer i from stdin and return f i; thus, if we enter 41 at the > keyboard, scanf "%d" f evaluates to 42. > This module provides general formatted input functions that read from any > kind of input, including strings, files, or anything that can return > characters. Hence, a typical call to a formatted input function bscan is bscan > ib fmt f, meaning that f should be applied to the arguments read from input ib, > according to the format string fmt. > The Caml scanning facility is reminiscent of the corresponding C feature. > However, it is also largely different, simpler, and yet more powerful: the > formatted input functions are higher-order functionals and the parameter > passing mechanism is simply the regular function application not the variable > assigment based mechanism which is typical of formatted input in imperative > languages; the format strings also feature useful additions to easily define > complex tokens; as expected of a functional programming language feature, the > formatted input functions support polymorphism, in particular arbitrary > interaction with polymorphic user-defined scanners. Furthermore, the Caml > formatted input facility is fully type-checked at compile time. 5699,5700c4865 < module Scanning : sig < >> --- > module Scanning : >> 5701a4867 > sig 5703a4870,4872 > << > type scanbuf > >> 5704a4874,4891 > The type of scanning buffers. A scanning buffer is the source from which > a formatted input function gets characters. The scanning buffer holds the > current state of the scan, plus a function to get the next char from the > input, and a token buffer to store the string matched so far. > Note: a scan may often require to examine one character in advance; when > this "lookahead" character does not belong to the token read, it is > stored back in the scanning buffer and becomes the next character read. > > << > val stdib : scanbuf > >> > > The scanning buffer reading from stdin. stdib is equivalent to > Scanning.from_channel stdin. > Note: when input is read interactively from stdin, the newline character > that triggers the evaluation is incorporated in the input; thus, scanning > specifications must properly skip this character (simply add a '\n' as > the last character of the format string). 5706,5708c4893,4895 < << < type scanbuf < >> --- > << > val from_string : string -> scanbuf > >> 5710,5714c4897,4899 < The type of scanning buffers. A scanning buffer is the argument < passed to the scanning functions used by the scanf family of < functions. The scanning buffer holds the current state of the < scan, plus a function to get the next char from the input, and < a token buffer to store the string matched so far. --- > Scanning.from_string s returns a scanning buffer 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. 5715a4901,4903 > << > val from_file : string -> scanbuf > >> 5716a4905,4909 > Bufferized file reading in text mode. The efficient and usual way to > scan text mode files (in effect, from_file returns a scanning buffer that > reads characters in large chunks, rather than one character at a time as > buffers returned by from_channel do). Scanning.from_file fname returns a > scanning buffer which reads from the given file fname in text mode. 5718,5720c4911,4913 < << < val from_string : string -> scanbuf < >> --- > << > val from_file_bin : string -> scanbuf > >> 5722,5725c4915 < Scanning.from_string s returns a scanning buffer 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. --- > Bufferized file reading in binary mode. 5726a4917,4919 > << > val from_function : (unit -> char) -> scanbuf > >> 5727a4921,4925 > Scanning.from_function f returns a scanning buffer 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. 5729c4927 < << --- > << 5731c4929 < >> --- > >> 5733,5735c4931,4933 < Scanning.from_channel inchan returns a scanning buffer which < reads from the input channel inchan, at the current reading < position. --- > Scanning.from_channel ic returns a scanning buffer which reads one > character at a time from the input channel ic, starting at the current > reading position. 5736a4935,4937 > << > val end_of_input : scanbuf -> bool > >> 5737a4939,4940 > Scanning.end_of_input ib tests the end-of-input condition of the given > scanning buffer. 5739,5741c4942,4944 < << < val from_function : (unit -> char) -> scanbuf < >> --- > << > val beginning_of_input : scanbuf -> bool > >> 5743,5747c4946,4947 < Scanning.from_function f returns a scanning buffer 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 set an end-of-input < condition by raising the exception End_of_file. --- > Scanning.beginning_of_input ib tests the beginning of input condition of > the given scanning buffer. 5748a4949,4951 > << > val name_of_input : scanbuf -> string > >> 5750,5752c4953,4954 < << < end < >> --- > Scanning.file_name_of_input ib returns the name of the character source > for the scanning buffer ib. 5753a4956 > end 5755,5756d4957 < 20.28 Module Set : Sets over ordered types. < *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= 5759,5763c4960,4961 < This module implements the set data structure, given a total ordering < function over the set elements. All operations over sets are purely < applicative (no side-effects). The implementation uses balanced binary trees, < and is therefore reasonably efficient: insertion and membership take time < logarithmic in the size of the set, for instance. --- > Scanning buffers > ================ 5767,5775c4965 < module type OrderedType = sig end < >> < [20.28.1] < << < module type S = sig end < >> < [20.28.2] < << < module Make : functor (Ord : OrderedType) -> sig end --- > exception Scan_failure of string 5777,5778d4966 < [20.28.3] < 5780,5783c4968,4969 < 20.28.1 Module type Set.OrderedType : Input signature of the functor < ===================================================================== < Set.Make[20.28.3]. < ================== --- > The exception raised by formatted input functions when the input cannot be > read according to the given format. 5786c4972,4973 < module type OrderedType = sig --- > type ('a, 'b, 'c, 'd) scanner = ('a, Scanning.scanbuf, 'b, 'c, 'a -> 'd, 'd) > format6 -> 'c 5788a4976,4989 > The type of formatted input scanners: ('a, 'b, 'c, 'd) scanner is the type > of a formatted input function that reads from some scanning buffer according > to some format string; more precisely, if scan is some formatted input > function, then scan ib fmt f applies f to the arguments specified by the > format string fmt, when scan has read those arguments from some scanning > buffer ib. > For instance, the scanf function below has type ('a, 'b, 'c, 'd) scanner, > since it is a formatted input function that reads from stdib: scanf fmt f > applies f to the arguments specified by fmt, reading those arguments from > stdin as expected. > If the format fmt has some %r indications, the corresponding input functions > must be provided before the f argument. For instance, if read_elem is an > input function for values of type t, then bscanf ib "%r;" read_elem f reads > a value of type t followed by a ';' character. 5791a4993,4994 > Formatted input functions > ========================= 5794c4997 < type t --- > val bscanf : Scanning.scanbuf -> ('a, 'b, 'c, 'd) scanner 5797,5799c5000,5013 < The type of the set elements. < < --- > bscanf ib fmt r1 ... rN f reads arguments for the function f from the > scanning buffer ib according to the format string fmt, and applies f to > these values. The result of this call to f is returned as the result of > bscanf. For instance, if f is the function fun s i -> i + 1, then > Scanf.sscanf "x = 1" "%s = %i" f returns 2. > Arguments r1 to rN are user-defined input functions that read the argument > corresponding to a %r conversion. > The format is a character string which contains three types of objects: > > - plain characters, which are simply matched with the characters of the > input, > - conversion specifications, each of which causes reading and conversion of > one argument for f, > - scanning indications to specify boundaries of tokens. 5801,5803c5015,5021 < << < val compare : t -> t -> int < >> --- > Among plain characters the space character (ASCII code 32) has a special > meaning: it matches "whitespace", that is any number of tab, space, line > feed and carriage return characters. Hence, a space in the format matches > any amount of whitespace in the input. > Conversion specifications consist in the % character, followed by an > optional flag, an optional field width, and followed by one or two > conversion characters. The conversion characters and their meanings are: 5805,5811d5022 < A total ordering function over the set elements. This is a < two-argument function f such that f e1 e2 is zero if the < elements e1 and e2 are equal, f e1 e2 is strictly negative if < e1 is smaller than e2, and f e1 e2 is strictly positive if e1 < is greater than e2. Example: a suitable ordering function is < the generic structural comparison function < Pervasives.compare[19.2]. 5812a5024,5083 > - d: reads an optionally signed decimal integer. > - i: reads an optionally signed integer (usual input formats for > hexadecimal (0x[d]+ and 0X[d]+), octal (0o[d]+), and binary 0b[d]+ > notations are understood). > - u: reads an unsigned decimal integer. > - x or X: reads an unsigned hexadecimal integer. > - o: reads an unsigned octal integer. > - s: reads a string argument that spreads as much as possible, until the > next white space, the next scanning indication, or the end-of-input is > reached. Hence, this conversion always succeeds: it returns an empty > string if the bounding condition holds when the scan begins. > - S: reads a delimited string argument (delimiters and special escaped > characters follow the lexical conventions of Caml). > - c: reads a single character. To test the current input character without > reading it, specify a null field width, i.e. use specification %0c. Raise > Invalid_argument, if the field width specification is greater than 1. > - C: reads a single delimited character (delimiters and special escaped > characters follow the lexical conventions of Caml). > - f, e, E, g, G: reads an optionally signed floating-point number in > decimal notation, in the style dddd.ddd e/E+-dd. > - F: reads a floating point number according to the lexical conventions of > Caml (hence the decimal point is mandatory if the exponent part is not > mentioned). > - B: reads a boolean argument (true or false). > - b: reads a boolean argument (for backward compatibility; do not use in > new programs). > - ld, li, lu, lx, lX, lo: reads an int32 argument to the format specified > by the second letter (decimal, hexadecimal, etc). > - nd, ni, nu, nx, nX, no: reads a nativeint argument to the format > specified by the second letter. > - Ld, Li, Lu, Lx, LX, Lo: reads an int64 argument to the format specified > by the second letter. > - [ range ]: reads characters that matches one of the characters mentioned > in the range of characters range (or not mentioned in it, if the range > starts with ^). Reads a string that can be empty, if the next input > character does not match the range. The set of characters from c1 to c2 > (inclusively) is denoted by c1-c2. Hence, %[0-9] returns a string > representing a decimal number or an empty string if no decimal digit is > found; similarly, %[\\048-\\057\\065-\\070] returns a string of > hexadecimal digits. If a closing bracket appears in a range, it must > occur as the first character of the range (or just after the ^ in case of > range negation); hence []] matches a ] character and [^]] matches any > character that is not ]. > - r: user-defined reader. Takes the next ri formatted input function and > applies it to the scanning buffer ib to read the next argument. The input > function ri must therefore have type Scanning.scanbuf -> 'a and the > argument read has type 'a. > - { fmt %}: reads a format string argument to the format specified by the > internal format fmt. The format string to be read must have the same type > as the internal format fmt. For instance, "%{%i%}" reads any format > string that can read a value of type int; hence Scanf.sscanf > "fmt:\\\"number is %u\\\"" "fmt:%{%i%}" succeeds and returns the format > string "number is %u". > - \( fmt %\): scanning format substitution. Reads a format string to > replace fmt. The format string read must have the same type as fmt. > - l: returns the number of lines read so far. > - n: returns the number of characters read so far. > - N or L: returns the number of tokens read so far. > - !: matches the end of input condition. > - %: matches one % character in the input. 5814,5816c5085,5111 < << < end < >> --- > Following the % character that introduces a conversion, there may be the > special flag _: the conversion that follows occurs as usual, but the > resulting value is discarded. For instance, if f is the function fun i -> i > + 1, then Scanf.sscanf "x = 1" "%_s = %i" f returns 2. > The field width is composed of an optional integer literal indicating the > maximal width of the token to read. For instance, %6d reads an integer, > having at most 6 decimal digits; %4f reads a float with at most 4 > characters; and %8[\\000-\\255] returns the next 8 characters (or all the > characters still available, if fewer than 8 characters are available in the > input). > Scanning indications appear just after the string conversions %s and %[ > range ] to delimit the end of the token. A scanning indication is introduced > by a @ character, followed by some constant character c. It means that the > string token should end just before the next matching c (which is skipped). > If no c character is encountered, the string token spreads as much as > possible. For instance, "%s@\t" reads a string up to the next tab character > or to the end of input. If a scanning indication @c does not follow a string > conversion, it is treated as a plain c character. > Raise Scanf.Scan_failure if the input does not match the format. > Raise Failure if a conversion to a number is not possible. > Raise End_of_file if the end of input is encountered while some more > characters are needed to read the current conversion specification. As a > consequence, scanning a %s conversion never raises exception End_of_file: if > the end of input is reached the conversion succeeds and simply returns the > characters read so far, or "" if none were read. > Raise Invalid_argument if the format string is invalid. > Notes: 5819,5820c5114,5120 < 20.28.2 Module type Set.S : Output signature of the functor Set.Make[20.28.3]. < =============================================================================== --- > - the scanning indications introduce slight differences in the syntax of > Scanf format strings compared to those used by the Printf module. > However, scanning indications are similar to those of the Format module; > hence, when producing formatted text to be scanned by !Scanf.bscanf, it > is wise to use printing functions from Format (or, if you need to use > functions from Printf, banish or carefully double check the format > strings that contain '@' characters). 5822,5824d5121 < << < module type S = sig < >> 5825a5123,5126 > - in addition to relevant digits, '_' characters may appear inside numbers > (this is reminiscent to the usual Caml lexical conventions). If stricter > scanning is desired, use the range conversion facility instead of the > number conversions. 5827a5129,5132 > - the scanf facility is not intended for heavy duty lexical analysis and > parsing. If it appears not expressive enough for your needs, several > alternative exists: regular expressions (module Str), stream parsers, > ocamllex-generated lexers, ocamlyacc-generated parsers. 5831c5136 < type elt --- > val fscanf : Pervasives.in_channel -> ('a, 'b, 'c, 'd) scanner 5834c5139,5152 < The type of the set elements. --- > Same as Scanf.bscanf[20.27], but reads from the given channel. > Warning: since all formatted input functions operate from a scanning buffer, > be aware that each fscanf invocation must allocate a new fresh scanning > buffer (unless you make careful use of partial application). Hence, there > are chances that some characters seem to be skipped (in fact they are > pending in the previously used scanning buffer). This happens in particular > when calling fscanf again after a scan involving a format that necessitated > some look ahead (such as a format that ends by skipping whitespace in the > input). > To avoid confusion, consider using bscanf with an explicitly created > scanning buffer. Use for instance Scanning.from_file f to allocate the > scanning buffer reading from file f. > This method is not only clearer it is also faster, since scanning buffers to > files are optimized for fast buffered reading. 5835a5154,5156 > << > val sscanf : string -> ('a, 'b, 'c, 'd) scanner > >> 5836a5158 > Same as Scanf.bscanf[20.27], but reads from the given string. 5839c5161 < type t --- > val scanf : ('a, 'b, 'c, 'd) scanner 5842c5164,5165 < The type of sets. --- > Same as Scanf.bscanf[20.27], but reads from the predefined scanning buffer > Scanf.Scanning.stdib[20.27] that is connected to stdin. 5843a5167,5171 > << > val kscanf : > Scanning.scanbuf -> > (Scanning.scanbuf -> exn -> 'a) -> ('b, 'c, 'd, 'a) scanner > >> 5844a5173,5177 > Same as Scanf.bscanf[20.27], but takes an additional function argument ef > that is called in case of error: if the scanning process or some conversion > fails, the scanning function aborts and calls the error handling function ef > with the scanning buffer and the exception that aborted the scanning > process. 5847c5180,5183 < val empty : t --- > val bscanf_format : > Scanning.scanbuf -> > ('a, 'b, 'c, 'd, 'e, 'f) format6 -> > (('a, 'b, 'c, 'd, 'e, 'f) format6 -> 'g) -> 'g 5850c5186,5189 < The empty set. --- > bscanf_format ib fmt f reads a format string token from the scannning > buffer ib, according to the given format string fmt, and applies f to the > resulting format string value. Raise Scan_failure if the format string value > read doesn't have the same type as fmt. 5851a5191,5196 > << > val sscanf_format : > string -> > ('a, 'b, 'c, 'd, 'e, 'f) format6 -> > (('a, 'b, 'c, 'd, 'e, 'f) format6 -> 'g) -> 'g > >> 5852a5198 > Same as Scanf.bscanf_format[20.27], but reads from the given string. 5855c5201,5203 < val is_empty : t -> bool --- > val format_from_string : > string -> > ('a, 'b, 'c, 'd, 'e, 'f) format6 -> ('a, 'b, 'c, 'd, 'e, 'f) format6 5858c5206,5208 < Test whether a set is empty or not. --- > format_from_string s fmt converts a string argument to a format string, > according to the given format string fmt. Raise Scan_failure if s, > considered as a format string, doesn't have the same type as fmt. 5862,5864c5212,5213 < << < val mem : elt -> t -> bool < >> --- > 20.28 Module Set : Sets over ordered types. > *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= 5866d5214 < mem x s tests whether x belongs to the set s. 5867a5216,5220 > This module implements the set data structure, given a total ordering > function over the set elements. All operations over sets are purely applicative > (no side-effects). The implementation uses balanced binary trees, and is > therefore reasonably efficient: insertion and membership take time logarithmic > in the size of the set, for instance. 5871,5872c5224 < val add : elt -> t -> t < >> --- > module type OrderedType = >> 5874,5875c5226 < add x s returns a set containing all elements of s, plus x. If < x was already in s, s is returned unchanged. --- > sig 5877a5229,5231 > << > type t > >> 5879,5881c5233 < << < val singleton : elt -> t < >> --- > The type of the set elements. 5883c5235,5237 < singleton x returns the one-element set containing only x. --- > << > val compare : t -> t -> int > >> 5884a5239,5244 > A total ordering function over the set elements. This is a two-argument > function f such that f e1 e2 is zero if the elements e1 and e2 are equal, > f e1 e2 is strictly negative if e1 is smaller than e2, and f e1 e2 is > strictly positive if e1 is greater than e2. Example: a suitable ordering > function is the generic structural comparison function > Pervasives.compare[19.2]. 5885a5246 > end 5887,5889c5248 < << < val remove : elt -> t -> t < >> --- > Input signature of the functor Set.Make[20.28]. 5891,5892c5250,5251 < remove x s returns a set containing all elements of s, except < x. If x was not in s, s is returned unchanged. --- > << > module type S = >> 5893a5253 > sig 5896,5898c5256,5258 < << < val union : t -> t -> t < >> --- > << > type elt > >> 5900c5260 < Set union. --- > The type of the set elements. 5901a5262,5264 > << > type t > >> 5902a5266 > The type of sets. 5904,5906c5268,5270 < << < val inter : t -> t -> t < >> --- > << > val empty : t > >> 5908c5272 < Set intersection. --- > The empty set. 5909a5274,5276 > << > val is_empty : t -> bool > >> 5910a5278 > Test whether a set is empty or not. 5912,5914c5280,5282 < << < val diff : t -> t -> t < >> --- > << > val mem : elt -> t -> bool > >> 5916c5284 < Set difference. --- > mem x s tests whether x belongs to the set s. 5917a5286,5288 > << > val add : elt -> t -> t > >> 5918a5290,5291 > add x s returns a set containing all elements of s, plus x. If x was > already in s, s is returned unchanged. 5920,5922c5293,5295 < << < val compare : t -> t -> int < >> --- > << > val singleton : elt -> t > >> 5924,5925c5297 < Total ordering between sets. Can be used as the ordering < function for doing sets of sets. --- > singleton x returns the one-element set containing only x. 5926a5299,5301 > << > val remove : elt -> t -> t > >> 5927a5303,5304 > remove x s returns a set containing all elements of s, except x. If x > was not in s, s is returned unchanged. 5929,5931c5306,5308 < << < val equal : t -> t -> bool < >> --- > << > val union : t -> t -> t > >> 5933,5934c5310 < equal s1 s2 tests whether the sets s1 and s2 are equal, that < is, contain equal elements. --- > Set union. 5935a5312,5314 > << > val inter : t -> t -> t > >> 5936a5316 > Set intersection. 5938,5940c5318,5320 < << < val subset : t -> t -> bool < >> --- > << > val diff : t -> t -> t > >> 5942,5943c5322 < subset s1 s2 tests whether the set s1 is a subset of the set < s2. --- > Set difference. 5944a5324,5326 > << > val compare : t -> t -> int > >> 5945a5328,5329 > Total ordering between sets. Can be used as the ordering function for > doing sets of sets. 5947,5949c5331,5333 < << < val iter : (elt -> unit) -> t -> unit < >> --- > << > val equal : t -> t -> bool > >> 5951,5952c5335,5336 < iter f s applies f in turn to all elements of s. The order in < which the elements of s are presented to f is unspecified. --- > equal s1 s2 tests whether the sets s1 and s2 are equal, that is, contain > equal elements. 5953a5338,5340 > << > val subset : t -> t -> bool > >> 5954a5342 > subset s1 s2 tests whether the set s1 is a subset of the set s2. 5956,5958c5344,5346 < << < val fold : (elt -> 'a -> 'a) -> t -> 'a -> 'a < >> --- > << > val iter : (elt -> unit) -> t -> unit > >> 5960,5962c5348,5350 < fold f s a computes (f xN ... (f x2 (f x1 a))...), where x1 < ... xN are the elements of s. The order in which elements of s < are presented to f is unspecified. --- > iter f s applies f in turn to all elements of s. The elements of s are > presented to f in increasing order with respect to the ordering over the > type of the elements. 5963a5352,5354 > << > val fold : (elt -> 'a -> 'a) -> t -> 'a -> 'a > >> 5964a5356,5357 > fold f s a computes (f xN ... (f x2 (f x1 a))...), where x1 ... xN are > the elements of s, in increasing order. 5966c5359 < << --- > << 5968,5972c5361 < >> < < for_all p s checks if all elements of the set satisfy the < predicate p. < --- > >> 5973a5363 > for_all p s checks if all elements of the set satisfy the predicate p. 5975c5365 < << --- > << 5977,5986c5367 < >> < < exists p s checks if at least one element of the set satisfies < the predicate p. < < < < << < val filter : (elt -> bool) -> t -> t < >> --- > >> 5988c5369 < filter p s returns the set of all elements in s that satisfy --- > exists p s checks if at least one element of the set satisfies the 5990a5372,5374 > << > val filter : (elt -> bool) -> t -> t > >> 5991a5376,5377 > filter p s returns the set of all elements in s that satisfy predicate > p. 5993c5379 < << --- > << 5995,6000c5381 < >> < < partition p s returns a pair of sets (s1, s2), where s1 is the < set of all the elements of s that satisfy the predicate p, and < s2 is the set of all the elements of s that do not satisfy p. < --- > >> 6001a5383,5385 > partition p s returns a pair of sets (s1, s2), where s1 is the set of > all the elements of s that satisfy the predicate p, and s2 is the set of > all the elements of s that do not satisfy p. 6003c5387 < << --- > << 6005c5389 < >> --- > >> 6009,6011c5393 < < < << --- > << 6013,6018c5395 < >> < < Return the list of all elements of the given set. The returned < list is sorted in increasing order with respect to the ordering < Ord.compare, where Ord is the argument given to < Set.Make[20.28.3]. --- > >> 6019a5397,5399 > Return the list of all elements of the given set. The returned list is > sorted in increasing order with respect to the ordering Ord.compare, > where Ord is the argument given to Set.Make[20.28]. 6021,6022c5401 < < << --- > << 6024c5403 < >> --- > >> 6026,6028c5405,5406 < Return the smallest element of the given set (with respect to < the Ord.compare ordering), or raise Not_found if the set is < empty. --- > Return the smallest element of the given set (with respect to the > Ord.compare ordering), or raise Not_found if the set is empty. 6030,6032c5408 < < < << --- > << 6034,6037c5410 < >> < < Same as Set.S.min_elt[20.28.2], but returns the largest element < of the given set. --- > >> 6038a5412,5413 > Same as Set.S.min_elt[20.28], but returns the largest element of the > given set. 6040,6041c5415 < < << --- > << 6043,6047c5417 < >> < < Return one element of the given set, or raise Not_found if the < set is empty. Which element is chosen is unspecified, but equal < elements will be chosen for equal sets. --- > >> 6048a5419,5430 > Return one element of the given set, or raise Not_found if the set is > empty. Which element is chosen is unspecified, but equal elements will be > chosen for equal sets. > > << > val split : elt -> t -> t * bool * t > >> > > split x s returns a triple (l, present, r), where l is the set of > elements of s that are strictly less than x; r is the set of elements of > s that are strictly greater than x; present is false if s contains no > element equal to x, or true if s contains an element equal to x. 6050d5431 < << 6052,6053d5432 < >> < 6055,6058c5434 < 20.28.3 Module Set.Make : Functor building an implementation of the set < ======================================================================== < structure given a totally ordered type. < ======================================== --- > Output signature of the functor Set.Make[20.28]. 6061,6067c5437 < module Make : sig < >> < < < Parameters: < < - Ord : Set.OrderedType --- > module Make : >> 6068a5439,5441 > functor (Ord : OrderedType) -> S with type elt = Ord.t > Functor building an implementation of the set structure given a totally > ordered type. 6071,6074d5443 < << < end < >> < 6084d5452 < 6089,6093c5457,5459 < Sort a list in increasing order according to an ordering < predicate. The predicate should return true if its first < argument is less than or equal to its second argument. < < --- > Sort a list in increasing order according to an ordering predicate. The > predicate should return true if its first argument is less than or equal to > its second argument. 6099,6104c5465,5467 < Sort an array in increasing order according to an ordering < predicate. The predicate should return true if its first < argument is less than or equal to its second argument. The < array is sorted in place. < < --- > Sort an array in increasing order according to an ordering predicate. The > predicate should return true if its first argument is less than or equal to > its second argument. The array is sorted in place. 6110,6115c5473,5476 < Merge two lists according to the given predicate. Assuming the < two argument lists are sorted according to the predicate, merge < returns a sorted list containing the elements from the two < lists. The behavior is undefined if the two argument lists were < not sorted. < --- > Merge two lists according to the given predicate. Assuming the two argument > lists are sorted according to the predicate, merge returns a sorted list > containing the elements from the two lists. The behavior is undefined if the > two argument lists were not sorted. 6126d5486 < 6133,6134d5492 < < 6139,6142c5497,5498 < Raised when Stack.pop[20.30] or Stack.top[20.30] is applied to < an empty stack. < < --- > Raised when Stack.pop[20.30] or Stack.top[20.30] is applied to an empty > stack. 6150,6151d5505 < < 6158,6159d5511 < < 6164,6167c5516,5517 < pop s removes and returns the topmost element in stack s, or < raises Empty if the stack is empty. < < --- > pop s removes and returns the topmost element in stack s, or raises Empty > if the stack is empty. 6173,6176c5523,5524 < top s returns the topmost element in stack s, or raises Empty < if the stack is empty. < < --- > top s returns the topmost element in stack s, or raises Empty if the stack > is empty. 6184,6185d5531 < < 6192,6193d5537 < < 6200,6201d5543 < < 6208,6209d5549 < < 6214,6217c5554,5556 < iter f s applies f in turn to all elements of s, from the < element at the top of the stack to the element at the bottom of < the stack. The stack itself is unchanged. < --- > iter f s applies f in turn to all elements of s, from the element at the > top of the stack to the element at the bottom of the stack. The stack itself > is unchanged. 6232,6252c5571 < module Array : sig end < >> < [20.31.1] < << < module List : sig end < >> < [20.31.2] < << < module String : sig end < >> < [20.31.3] < < < 20.31.1 Module StdLabels.Array < =============================== < < << < module Array : sig < >> < < --- > module Array : >> 6253a5573 > sig 6256c5576 < << --- > << 6258,6259c5578 < >> < --- > >> 6261c5580 < << --- > << 6263c5582 < >> --- > >> 6265,6266c5584 < < << --- > << 6268,6269c5586 < >> < --- > >> 6271c5588 < << --- > << 6273,6274c5590 < >> < --- > >> 6276c5592 < << --- > << 6278c5594 < >> --- > >> 6280,6281c5596 < < << --- > << 6283c5598 < >> --- > >> 6285,6286c5600 < < << --- > << 6288,6289c5602 < >> < --- > >> 6291c5604 < << --- > << 6293,6294c5606 < >> < --- > >> 6296c5608 < << --- > << 6298c5610 < >> --- > >> 6300,6301c5612 < < << --- > << 6303,6304c5614 < >> < --- > >> 6306c5616 < << --- > << 6308,6309c5618 < >> < --- > >> 6311c5620 < << --- > << 6313c5622 < >> --- > >> 6315,6316c5624 < < << --- > << 6318c5626 < >> --- > >> 6320,6321c5628 < < << --- > << 6323,6326c5630,5632 < src:'a array -> < src_pos:int -> dst:'a array -> dst_pos:int -> len:int -> unit < >> < --- > src:'a array -> src_pos:int -> dst:'a array -> dst_pos:int -> len:int -> > unit > >> 6328c5634 < << --- > << 6330,6331c5636 < >> < --- > >> 6333c5638 < << --- > << 6335c5640 < >> --- > >> 6337,6338c5642 < < << --- > << 6340,6341c5644 < >> < --- > >> 6343c5646 < << --- > << 6345,6346c5648 < >> < --- > >> 6348c5650 < << --- > << 6350c5652 < >> --- > >> 6352,6353c5654 < < << --- > << 6355c5656 < >> --- > >> 6357,6358c5658 < < << --- > << 6360,6361c5660 < >> < --- > >> 6363c5662 < << --- > << 6365,6366c5664 < >> < --- > >> 6368c5666 < << --- > << 6370c5668 < >> --- > >> 6372,6373c5670 < < << --- > << 6375c5672 < >> --- > >> 6376a5674,5676 > << > val fast_sort : cmp:('a -> 'a -> int) -> 'a array -> unit > >> 6378c5678 < << --- > << 6380c5680 < >> --- > >> 6382,6383c5682 < < << --- > << 6385c5684 < >> --- > >> 6387d5685 < << 6389,6393d5686 < >> < < < 20.31.2 Module StdLabels.List < ============================== 6396,6399c5689 < module List : sig < >> < < --- > module List : >> 6400a5691 > sig 6403c5694 < << --- > << 6405,6406c5696 < >> < --- > >> 6408c5698 < << --- > << 6410c5700 < >> --- > >> 6412,6413c5702 < < << --- > << 6415,6416c5704 < >> < --- > >> 6418c5706 < << --- > << 6420,6421c5708 < >> < --- > >> 6423c5710 < << --- > << 6425c5712 < >> --- > >> 6427,6428c5714 < < << --- > << 6430c5716 < >> --- > >> 6432,6433c5718 < < << --- > << 6435,6436c5720 < >> < --- > >> 6438c5722 < << --- > << 6440,6441c5724 < >> < --- > >> 6443c5726 < << --- > << 6445c5728 < >> --- > >> 6447,6448c5730 < < << --- > << 6450,6451c5732 < >> < --- > >> 6453c5734 < << --- > << 6455,6456c5736 < >> < --- > >> 6458c5738 < << --- > << 6460c5740 < >> --- > >> 6462,6463c5742 < < << --- > << 6465c5744 < >> --- > >> 6467,6468c5746 < < << --- > << 6470,6471c5748 < >> < --- > >> 6473c5750 < << --- > << 6475,6476c5752 < >> < --- > >> 6478c5754 < << --- > << 6480c5756 < >> --- > >> 6482,6483c5758 < < << --- > << 6485,6486c5760 < >> < --- > >> 6488c5762 < << --- > << 6491,6492c5765 < >> < --- > >> 6494c5767 < << --- > << 6497c5770 < >> --- > >> 6499,6500c5772 < < << --- > << 6502c5774 < >> --- > >> 6504,6505c5776 < < << --- > << 6507,6508c5778 < >> < --- > >> 6510c5780 < << --- > << 6512,6513c5782 < >> < --- > >> 6515c5784 < << --- > << 6517c5786 < >> --- > >> 6519,6520c5788 < < << --- > << 6522,6523c5790 < >> < --- > >> 6525c5792 < << --- > << 6527,6528c5794 < >> < --- > >> 6530c5796 < << --- > << 6532c5798 < >> --- > >> 6534,6535c5800 < < << --- > << 6537c5802 < >> --- > >> 6539,6540c5804 < < << --- > << 6542,6543c5806 < >> < --- > >> 6545c5808 < << --- > << 6547,6548c5810 < >> < --- > >> 6550c5812 < << --- > << 6552c5814 < >> --- > >> 6554,6555c5816 < < << --- > << 6557,6558c5818 < >> < --- > >> 6560c5820 < << --- > << 6562,6563c5822 < >> < --- > >> 6565c5824 < << --- > << 6567c5826 < >> --- > >> 6569,6570c5828 < < << --- > << 6572c5830 < >> --- > >> 6574,6575c5832 < < << --- > << 6577,6578c5834 < >> < --- > >> 6580c5836 < << --- > << 6582,6583c5838 < >> < --- > >> 6585c5840 < << --- > << 6587c5842 < >> --- > >> 6589,6590c5844 < < << --- > << 6592,6593c5846 < >> < --- > >> 6595c5848 < << --- > << 6597c5850 < >> --- > >> 6599,6601c5852,5858 < << < end < >> --- > << > val fast_sort : cmp:('a -> 'a -> int) -> 'a list -> 'a list > >> > > << > val merge : cmp:('a -> 'a -> int) -> 'a list -> 'a list -> 'a list > >> 6603,6605c5860 < < 20.31.3 Module StdLabels.String < ================================ --- > end 6608,6609c5863 < module String : sig < >> --- > module String : >> 6610a5865 > sig 6613,6615c5868 < < < << --- > << 6617c5870 < >> --- > >> 6619,6620c5872 < < << --- > << 6622c5874 < >> --- > >> 6624,6625c5876 < < << --- > << 6627,6628c5878 < >> < --- > >> 6630c5880 < << --- > << 6632,6633c5882 < >> < --- > >> 6635c5884 < << --- > << 6637c5886 < >> --- > >> 6639,6640c5888 < < << --- > << 6642,6643c5890 < >> < --- > >> 6645c5892 < << --- > << 6647,6648c5894 < >> < --- > >> 6650c5896 < << --- > << 6652c5898 < >> --- > >> 6654,6655c5900 < < << --- > << 6657,6658c5902,5904 < src:string -> src_pos:int -> dst:string -> dst_pos:int -> len:int -> unit < >> --- > src:string -> src_pos:int -> dst:string -> dst_pos:int -> len:int -> > unit > >> 6660,6661c5906 < < << --- > << 6663,6664c5908 < >> < --- > >> 6666c5910 < << --- > << 6668,6669c5912 < >> < --- > >> 6671c5914 < << --- > << 6673c5916 < >> --- > >> 6675,6676c5918 < < << --- > << 6678,6679c5920 < >> < --- > >> 6681c5922 < << --- > << 6683,6684c5924 < >> < --- > >> 6686c5926 < << --- > << 6688c5928 < >> --- > >> 6690,6691c5930 < < << --- > << 6693c5932 < >> --- > >> 6695,6696c5934 < < << --- > << 6698,6699c5936 < >> < --- > >> 6701c5938 < << --- > << 6703,6704c5940 < >> < --- > >> 6706c5942 < << --- > << 6708c5944 < >> --- > >> 6710,6711c5946 < < << --- > << 6713,6714c5948 < >> < --- > >> 6716c5950 < << --- > << 6718,6719c5952 < >> < --- > >> 6721c5954 < << --- > << 6723c5956 < >> --- > >> 6725,6726c5958 < < << --- > << 6728c5960 < >> --- > >> 6729a5962,5964 > << > type t = string > >> 6731,6733c5966,5968 < << < val unsafe_get : string -> int -> char < >> --- > << > val compare : t -> t -> int > >> 6734a5970,5972 > << > val unsafe_get : string -> int -> char > >> 6736c5974 < << --- > << 6738,6739c5976 < >> < --- > >> 6741c5978 < << --- > << 6743,6745c5980,5982 < src:string -> src_pos:int -> dst:string -> dst_pos:int -> len:int -> unit < >> < --- > src:string -> src_pos:int -> dst:string -> dst_pos:int -> len:int -> > unit > >> 6747c5984 < << --- > << 6749c5986 < >> --- > >> 6751d5987 < << 6753c5989 < >> --- > 6762d5997 < 6769,6770d6003 < < 6775,6778c6008,6009 < Raised by parsers when none of the first components of the < stream patterns is accepted. < < --- > Raised by parsers when none of the first components of the stream patterns > is accepted. 6784,6785c6015,6016 < Raised by parsers when the first component of a stream pattern < is accepted, but one of the following components is rejected. --- > Raised by parsers when the first component of a stream pattern is accepted, > but one of the following components is rejected. 6793,6795c6024,6025 < mix them with streams built with [< >]; would raise Failure when accessing < such mixed streams. < --- > mix them with streams built with [< >]; would raise Failure when accessing such > mixed streams. 6800,6806c6030,6033 < Stream.from f returns a stream built from the function f. To < create a new stream element, the function f is called with the < current stream count. The user function f must return either < Some <value> for a value or None to specify the end of the < stream. < < --- > Stream.from f returns a stream built from the function f. To create a new > stream element, the function f is called with the current stream count. The > user function f must return either Some <value> for a value or None to > specify the end of the stream. 6812,6815c6039 < Return the stream holding the elements of the list in the same < order. < < --- > Return the stream holding the elements of the list in the same order. 6823,6824d6046 < < 6829,6830c6051 < Return the stream of the characters read from the input < channel. --- > Return the stream of the characters read from the input channel. 6837d6057 < 6842,6843c6062,6063 < Stream.iter f s scans the whole stream s, applying function f < in turn to each stream element encountered. --- > Stream.iter f s scans the whole stream s, applying function f in turn to > each stream element encountered. 6850d6069 < 6855,6858c6074,6075 < Return the first element of the stream and remove it from the < stream. Raise Stream.Failure if the stream is empty. < < --- > Return the first element of the stream and remove it from the stream. Raise > Stream.Failure if the stream is empty. 6871d6087 < 6876,6879c6092,6093 < Return Some of "the first element" of the stream, or None if < the stream is empty. < < --- > Return Some of "the first element" of the stream, or None if the stream is > empty. 6885,6888c6099 < Remove the first element of the stream, possibly unfreezing it < before. < < --- > Remove the first element of the stream, possibly unfreezing it before. 6894,6897c6105,6106 < Return the current count of the stream elements, i.e. the < number of the stream elements discarded. < < --- > Return the current count of the stream elements, i.e. the number of the > stream elements discarded. 6903,6906c6112,6113 < npeek n returns the list of the n first elements of the < stream, or all its remaining elements if less than n elements < are available. < --- > npeek n returns the list of the n first elements of the stream, or all its > remaining elements if less than n elements are available. 6916d6122 < 6923,6924d6128 < < 6929,6935c6133,6137 < String.get s n returns character number n in string s. The < first character is character number 0. The last character is < character number String.length s - 1. Raise Invalid_argument if < n is outside the range 0 to (String.length s - 1). You can < also write s.[n] instead of String.get s n. < < --- > String.get s n returns character number n in string s. The first character > is character number 0. The last character is character number String.length > s - 1. You can also write s.[n] instead of String.get s n. > Raise Invalid_argument "index out of bounds" if n is outside the range 0 to > (String.length s - 1). 6941,6946c6143,6146 < String.set s n c modifies string s in place, replacing the < character number n by c. Raise Invalid_argument if n is outside < the range 0 to (String.length s - 1). You can also write s.[n] < <- c instead of String.set s n c. < < --- > String.set s n c modifies string s in place, replacing the character number > n by c. You can also write s.[n] <- c instead of String.set s n c. Raise > Invalid_argument "index out of bounds" if n is outside the range 0 to > (String.length s - 1). 6952,6956c6152,6154 < String.create n returns a fresh string of length n. The string < initially contains arbitrary characters. Raise Invalid_argument < if n < 0 or n > Sys.max_string_length. < < --- > String.create n returns a fresh string of length n. The string initially > contains arbitrary characters. Raise Invalid_argument if n < 0 or n > > Sys.max_string_length. 6962,6963c6160,6161 < String.make n c returns a fresh string of length n, filled < with the character c. Raise Invalid_argument if n < 0 or n > --- > String.make n c returns a fresh string of length n, filled with the > character c. Raise Invalid_argument if n < 0 or n > 6966,6967d6163 < < 6974,6975d6169 < < 6980,6986c6174,6177 < String.sub s start len returns a fresh string of length len, < containing the characters number start to start + len - 1 of < string s. Raise Invalid_argument if start and len do not < designate a valid substring of s; that is, if start < 0, or len < < 0, or start + len > String.length[20.33] s. < < --- > String.sub s start len returns a fresh string of length len, containing the > characters number start to start + len - 1 of string s. Raise > Invalid_argument if start and len do not designate a valid substring of s; > that is, if start < 0, or len < 0, or start + len > String.length[20.33] s. 6992,6997c6183,6185 < String.fill s start len c modifies string s in place, < replacing the characters number start to start + len - 1 by c. < Raise Invalid_argument if start and len do not designate a < valid substring of s. < < --- > String.fill s start len c modifies string s in place, replacing the > characters number start to start + len - 1 by c. Raise Invalid_argument if > start and len do not designate a valid substring of s. 7003,7011c6191,6196 < String.blit src srcoff dst dstoff len copies len characters < from string src, starting at character number srcoff, to string < dst, starting at character number dstoff. It works correctly < even if src and dst are the same string, and the source and < destination chunks overlap. Raise Invalid_argument if srcoff < and len do not designate a valid substring of src, or if dstoff < and len do not designate a valid substring of dst. < < --- > String.blit src srcoff dst dstoff len copies len characters from string > src, starting at character number srcoff, to string dst, starting at > character number dstoff. It works correctly even if src and dst are the same > string, and the source and destination chunks overlap. Raise > Invalid_argument if srcoff and len do not designate a valid substring of > src, or if dstoff and len do not designate a valid substring of dst. 7017,7020c6202,6203 < String.concat sep sl concatenates the list of strings sl, < inserting the separator string sep between each. < < --- > String.concat sep sl concatenates the list of strings sl, inserting the > separator string sep between each. 7026,7030c6209,6210 < 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.length s - 1); (). < < --- > 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.length s - 1]; (). 7036,7041c6216,6219 < Return a copy of the argument, with special characters < represented by escape sequences, following the lexical < conventions of Objective Caml. If there is no special character < in the argument, return the original string itself, not a copy. < < --- > Return a copy of the argument, with special characters represented by > escape sequences, following the lexical conventions of Objective Caml. If > there is no special character in the argument, return the original string > itself, not a copy. 7047,7051c6225,6226 < String.index s c returns the position of the leftmost < occurrence of character c in string s. Raise Not_found if c < does not occur in s. < < --- > String.index s c returns the position of the leftmost occurrence of > character c in string s. Raise Not_found if c does not occur in s. 7057,7061c6232,6233 < String.rindex s c returns the position of the rightmost < occurrence of character c in string s. Raise Not_found if c < does not occur in s. < < --- > String.rindex s c returns the position of the rightmost occurrence of > character c in string s. Raise Not_found if c does not occur in s. 7067,7071c6239,6241 < Same as String.index[20.33], but start searching at the < character position given as second argument. String.index s c < is equivalent to String.index_from s 0 c. < < --- > Same as String.index[20.33], but start searching at the character position > given as second argument. String.index s c is equivalent to > String.index_from s 0 c. 7077,7081c6247,6249 < Same as String.rindex[20.33], but start searching at the < character position given as second argument. String.rindex s c < is equivalent to String.rindex_from s (String.length s - 1) c. < < --- > Same as String.rindex[20.33], but start searching at the character position > given as second argument. String.rindex s c is equivalent to > String.rindex_from s (String.length s - 1) c. 7087,7090c6255 < String.contains s c tests if character c appears in the string < s. < < --- > String.contains s c tests if character c appears in the string s. 7096,7100c6261,6263 < String.contains_from s start c tests if character c appears in < the substring of s starting from start to the end of s. Raise < Invalid_argument if start is not a valid index of s. < < --- > String.contains_from s start c tests if character c appears in the > substring of s starting from start to the end of s. Raise Invalid_argument > if start is not a valid index of s. 7106,7110c6269,6271 < String.rcontains_from s stop c tests if character c appears in < the substring of s starting from the beginning of s to index < stop. Raise Invalid_argument if stop is not a valid index of s. < < --- > String.rcontains_from s stop c tests if character c appears in the > substring of s starting from the beginning of s to index stop. Raise > Invalid_argument if stop is not a valid index of s. 7116,7120c6277,6279 < Return a copy of the argument, with all lowercase letters < translated to uppercase, including accented letters of the ISO < Latin-1 (8859-1) character set. < < --- > Return a copy of the argument, with all lowercase letters translated to > uppercase, including accented letters of the ISO Latin-1 (8859-1) character > set. 7126,7130c6285,6287 < Return a copy of the argument, with all uppercase letters < translated to lowercase, including accented letters of the ISO < Latin-1 (8859-1) character set. < < --- > Return a copy of the argument, with all uppercase letters translated to > lowercase, including accented letters of the ISO Latin-1 (8859-1) character > set. 7136,7139c6293 < Return a copy of the argument, with the first letter set to < uppercase. < < --- > Return a copy of the argument, with the first character set to uppercase. 7145,7148c6299 < Return a copy of the argument, with the first letter set to < lowercase. < < --- > Return a copy of the argument, with the first character set to lowercase. 7156,7157d6306 < < 7162,7167c6311,6314 < The comparison function for strings, with the same < specification as Pervasives.compare[19.2]. Along with the type < t, this function compare allows the module String to be passed < as argument to the functors Set.Make[20.28.3] and < Map.Make[20.18.3]. < --- > The comparison function for strings, with the same specification as > Pervasives.compare[19.2]. Along with the type t, this function compare > allows the module String to be passed as argument to the functors > Set.Make[20.28] and Map.Make[20.18]. 7177d6323 < 7182,7187c6328,6330 < The command line arguments given to the process. The first < element is the command name used to invoke the program. The < following elements are the command-line arguments given to the < program. < < --- > The command line arguments given to the process. The first element is the > command name used to invoke the program. The following elements are the > command-line arguments given to the program. 7193,7196c6336 < The name of the file containing the executable currently < running. < < --- > The name of the file containing the executable currently running. 7203a6344,6346 > << > val is_directory : string -> bool > >> 7204a6348,6349 > Returns true if the given name refers to a directory, false if it refers to > another kind of file. Raise Sys_error if no file exists with the given name. 7212,7213d6356 < < 7218,7221c6361,6363 < Rename a file. The first argument is the old name and the < second is the new name. < < --- > Rename a file. The first argument is the old name and the second is the new > name. If there is already another file under the new name, rename may > replace it, or raise an exception, depending on your operating system. 7227,7230c6369,6370 < Return the value associated to a variable in the process < environment. Raise Not_found if the variable is unbound. < < --- > Return the value associated to a variable in the process environment. Raise > Not_found if the variable is unbound. 7238,7239d6377 < < 7244,7247c6382,6383 < Return the processor time, in seconds, used by the program < since the beginning of execution. < < --- > Return the processor time, in seconds, used by the program since the > beginning of execution. 7255,7256d6390 < < 7262a6397,6399 > << > val readdir : string -> string array > >> 7263a6401,6406 > Return the names of all files present in the given directory. Names > denoting the current directory and the parent directory ("." and ".." in > Unix) are not returned. Each string in the result is a file name rather than > a complete path. There is no guarantee that the name strings in the > resulting array will appear in any specific order; they are not, in > particular, guaranteed to appear in alphabetical order. 7269,7273c6412,6413 < This reference is initially set to false in standalone < programs and to true if the code is being executed under the < interactive toplevel system ocaml. < < --- > This reference is initially set to false in standalone programs and to true > if the code is being executed under the interactive toplevel system ocaml. 7280,7283d6419 < "Unix" (for all Unix versions, including Linux and Mac OS X), < "Win32" (for MS-Windows, OCaml compiled with MSVC++), "Cygwin" < (for MS-Windows, OCaml compiled with Cygwin), "MacOS" (for < MacOS 9). 7284a6421,6423 > - "Unix" (for all Unix versions, including Linux and Mac OS X), > - "Win32" (for MS-Windows, OCaml compiled with MSVC++ or Mingw), > - "Cygwin" (for MS-Windows, OCaml compiled with Cygwin). 7291,7294c6430,6431 < Size of one word on the machine currently executing the Caml < program, in bits: 32 or 64. < < --- > Size of one word on the machine currently executing the Caml program, in > bits: 32 or 64. 7302,7303d6438 < < 7308c6443,6445 < Maximum length of an array. --- > Maximum length of a normal array. The maximum length of a float array is > max_array_length/2 on 32-bit machines and max_array_length on 64-bit > machines. 7315d6451 < 7325,7326c6461 < - Signal_default: take the default behavior (usually: abort < the program) --- > - Signal_default: take the default behavior (usually: abort the program) 7328,7330c6463,6464 < - Signal_handle f: call function f, giving it the signal < number as argument. < --- > - Signal_handle f: call function f, giving it the signal number as > argument. 7337,7341c6471,6474 < Set the behavior of the system on receipt of a given signal. < The first argument is the signal number. Return the behavior < previously associated with the signal. < < --- > Set the behavior of the system on receipt of a given signal. The first > argument is the signal number. Return the behavior previously associated > with the signal. If the signal number is invalid (or not available on your > system), an Invalid_argument exception is raised. 7354d6486 < 7361,7362d6492 < < 7369,7370d6498 < < 7377,7378d6504 < < 7385,7386d6510 < < 7393,7394d6516 < < 7401,7402d6522 < < 7409,7410d6528 < < 7417,7418d6534 < < 7425,7426d6540 < < 7433,7434d6546 < < 7441,7442d6552 < < 7449,7450d6558 < < 7457,7458d6564 < < 7465,7466d6570 < < 7473,7474d6576 < < 7481,7482d6582 < < 7489,7490d6588 < < 7497,7498d6594 < < 7505,7506d6600 < < 7513,7514d6606 < < 7521,7522d6612 < < 7527,7530c6617 < Exception raised on interactive interrupt if < Sys.catch_break[20.34] is on. < < --- > Exception raised on interactive interrupt if Sys.catch_break[20.34] is on. 7536,7541c6623,6626 < catch_break governs whether interactive interrupt (ctrl-C) < terminates the program or raises the Break exception. Call < catch_break true to enable raising Break, and catch_break false < to let the system terminate the program on user interrupt. < < --- > catch_break governs whether interactive interrupt (ctrl-C) terminates the > program or raises the Break exception. Call catch_break true to enable > raising Break, and catch_break false to let the system terminate the program > on user interrupt. 7547,7551c6632,6635 < ocaml_version is the version of Objective Caml. It is a string < of the form "major.minor[additional-info]" Where major and < minor are integers, and additional-info is a string that is < empty or starts with a '+'. < --- > ocaml_version is the version of Objective Caml. It is a string of the form > "major.minor[.patchlevel][+additional-info]", where major, minor, and > patchlevel are integers, and additional-info is an arbitrary string. The > [.patchlevel] and [+additional-info] parts may be absent. 7561a6646 > 7565d6649 < 7570,7575c6654,6658 < The type of arrays of weak pointers (weak arrays). A weak < pointer is a value that the garbage collector may erase at any < time. A weak pointer is said to be full if it points to a < value, empty if the value was erased by the GC. < < --- > The type of arrays of weak pointers (weak arrays). A weak pointer is a > value that the garbage collector may erase at any time. A weak pointer is > said to be full if it points to a value, empty if the value was erased by > the GC. Note that weak arrays cannot be marshaled using > Pervasives.output_value[19.2] or the functions of the Marshal[20.19] module. 7581,7585c6664,6666 < Weak.create n returns a new weak array of length n. All the < pointers are initially empty. Raise Invalid_argument if n is < negative or greater than Sys.max_array_length[20.34]-1. < < --- > Weak.create n returns a new weak array of length n. All the pointers are > initially empty. Raise Invalid_argument if n is negative or greater than > Sys.max_array_length[20.34]-1. 7593,7594d6673 < < 7599,7604c6678,6681 < Weak.set ar n (Some el) sets the nth cell of ar to be a (full) < pointer to el; Weak.set ar n None sets the nth cell of ar to < empty. Raise Invalid_argument "Weak.set" if n is not in the < range 0 to Weak.length[20.35] a - 1. < < --- > Weak.set ar n (Some el) sets the nth cell of ar to be a (full) pointer to > el; Weak.set ar n None sets the nth cell of ar to empty. Raise > Invalid_argument "Weak.set" if n is not in the range 0 to Weak.length[20.35] > a - 1. 7610,7615c6687,6689 < Weak.get ar n returns None if the nth cell of ar is empty, < Some x (where x is the value) if it is full. Raise < Invalid_argument "Weak.get" if n is not in the range 0 to < Weak.length[20.35] a - 1. < < --- > Weak.get ar n returns None if the nth cell of ar is empty, Some x (where x > is the value) if it is full. Raise Invalid_argument "Weak.get" if n is not > in the range 0 to Weak.length[20.35] a - 1. 7621,7630c6695,6701 < Weak.get_copy ar n returns None if the nth cell of ar is < empty, Some x (where x is a (shallow) copy of the value) if it < is full. In addition to pitfalls with mutable values, the < interesting difference with get is that get_copy does not < prevent the incremental GC from erasing the value in its < current cycle (get may delay the erasure to the next GC cycle). < Raise Invalid_argument "Weak.get" if n is not in the range 0 < to Weak.length[20.35] a - 1. < < --- > Weak.get_copy ar n returns None if the nth cell of ar is empty, Some x > (where x is a (shallow) copy of the value) if it is full. In addition to > pitfalls with mutable values, the interesting difference with get is that > get_copy does not prevent the incremental GC from erasing the value in its > current cycle (get may delay the erasure to the next GC cycle). Raise > Invalid_argument "Weak.get" if n is not in the range 0 to Weak.length[20.35] > a - 1. 7636,7640c6707,6709 < Weak.check ar n returns true if the nth cell of ar is full, < false if it is empty. Note that even if Weak.check ar n returns < true, a subsequent Weak.get[20.35] ar n can return None. < < --- > Weak.check ar n returns true if the nth cell of ar is full, false if it is > empty. Note that even if Weak.check ar n returns true, a subsequent > Weak.get[20.35] ar n can return None. 7646,7650c6715,6717 < Weak.fill ar ofs len el sets to el all pointers of ar from ofs < to ofs + len - 1. Raise Invalid_argument "Weak.fill" if ofs and < len do not designate a valid subarray of a. < < --- > Weak.fill ar ofs len el sets to el all pointers of ar from ofs to ofs + len > - 1. Raise Invalid_argument "Weak.fill" if ofs and len do not designate a > valid subarray of a. 7656,7660c6723,6726 < Weak.blit ar1 off1 ar2 off2 len copies len weak pointers from < ar1 (starting at off1) to ar2 (starting at off2). It works < correctly even if ar1 and ar2 are the same. Raise < Invalid_argument "Weak.blit" if off1 and len do not designate a < valid subarray of ar1, or if off2 and len do not designate a --- > Weak.blit ar1 off1 ar2 off2 len copies len weak pointers from ar1 (starting > at off1) to ar2 (starting at off2). It works correctly even if ar1 and ar2 > are the same. Raise Invalid_argument "Weak.blit" if off1 and len do not > designate a valid subarray of ar1, or if off2 and len do not designate a 7669,7674c6735,6739 < disappear from the set when it is not used by the rest of the program any < more. This is normally used to share data structures without inducing memory < leaks. Weak hash tables are defined on values from a < Hashtbl.HashedType[20.12.1] module; the equal relation and hash function are < taken from that module. We will say that v is an instance of x if equal x v < is true. --- > disappear from the set when it is not used by the rest of the program any more. > This is normally used to share data structures without inducing memory leaks. > Weak hash tables are defined on values from a Hashtbl.HashedType[20.12] module; > the equal relation and hash function are taken from that module. We will say > that v is an instance of x if equal x v is true. 7676c6741 < give the same result as with the value itself. --- > give the same result as with the values themselves. 7678,7696c6743 < module type S = sig end < >> < [20.35.1] < << < module Make : functor (H : Hashtbl.HashedType) -> sig end < >> < [20.35.2] < < < 20.35.1 Module type Weak.S : The output signature of the functor < ================================================================= < Weak.Make[20.35.2]. < =================== < < << < module type S = sig < >> < < --- > module type S = >> 7697a6745 > sig 7700c6748 < << --- > << 7702c6750 < >> --- > >> 7706,7708c6754 < < < << --- > << 7710,7713c6756 < >> < < The type of tables that contain elements of type data. < --- > >> 7714a6758,6760 > The type of tables that contain elements of type data. Note that weak > hash tables cannot be marshaled using Pervasives.output_value[19.2] or > the functions of the Marshal[20.19] module. 7716c6762 < << --- > << 7718,7722c6764 < >> < < create n creates a new empty weak hash table, of initial size < n. The table will grow as needed. < --- > >> 7723a6766,6767 > create n creates a new empty weak hash table, of initial size n. The > table will grow as needed. 7725c6769 < << --- > << 7727c6771 < >> --- > >> 7731,7733c6775 < < < << --- > << 7735,7739c6777 < >> < < merge t x returns an instance of x found in t if any, or else < adds x to t and return x. < --- > >> 7740a6779,6780 > merge t x returns an instance of x found in t if any, or else adds x to > t and return x. 7742c6782 < << --- > << 7744,7749c6784 < >> < < add t x adds x to t. If there is already an instance of x in < t, it is unspecified which one will be returned by subsequent < calls to find and merge. < --- > >> 7750a6786,6788 > add t x adds x to t. If there is already an instance of x in t, it is > unspecified which one will be returned by subsequent calls to find and > merge. 7752c6790 < << --- > << 7754,7758c6792 < >> < < remove t x removes from t one instance of x. Does nothing if < there is no instance of x in t. < --- > >> 7759a6794,6795 > remove t x removes from t one instance of x. Does nothing if there is no > instance of x in t. 7761c6797 < << --- > << 7763,7767c6799 < >> < < find t x returns an instance of x found in t. Raise Not_found < if there is no such element. < --- > >> 7768a6801,6802 > find t x returns an instance of x found in t. Raise Not_found if there > is no such element. 7770c6804 < << --- > << 7772,7776c6806 < >> < < find_all t x returns a list of all the instances of x found in < t. < --- > >> 7777a6808 > find_all t x returns a list of all the instances of x found in t. 7779c6810 < << --- > << 7781,7785c6812 < >> < < mem t x returns true if there is at least one instance of x in < t, false otherwise. < --- > >> 7786a6814,6815 > mem t x returns true if there is at least one instance of x in t, false > otherwise. 7788c6817 < << --- > << 7790,7794c6819 < >> < < iter f t calls f on each element of t, in some unspecified < order. It is not specified what happens if f tries to change t < itself. --- > >> 7795a6821,6822 > iter f t calls f on each element of t, in some unspecified order. It is > not specified what happens if f tries to change t itself. 7797,7798c6824 < < << --- > << 7800,7804c6826 < >> < < fold f t init computes (f d1 (... (f dN init))) where d1 ... < dN are the elements of t in some unspecified order. It is not < specified what happens if f tries to change t itself. --- > >> 7805a6828,6830 > fold f t init computes (f d1 (... (f dN init))) where d1 ... dN are the > elements of t in some unspecified order. It is not specified what happens > if f tries to change t itself. 7807,7808c6832 < < << --- > << 7810,7814c6834 < >> < < Count the number of elements in the table. count t gives the < same result as fold (fun _ n -> n+1) t 0 but does not delay the < deallocation of the dead elements. --- > >> 7815a6836,6838 > Count the number of elements in the table. count t gives the same result > as fold (fun _ n -> n+1) t 0 but does not delay the deallocation of the > dead elements. 7817,7818c6840 < < << --- > << 7820,7825c6842 < >> < < Return statistics on the table. The numbers are, in order: < table length, number of entries, sum of bucket lengths, < smallest bucket length, median bucket length, biggest bucket < length. --- > >> 7826a6844,6846 > Return statistics on the table. The numbers are, in order: table length, > number of entries, sum of bucket lengths, smallest bucket length, median > bucket length, biggest bucket length. 7828d6847 < << 7830d6848 < >> 7832,7836c6850 < < 20.35.2 Module Weak.Make : Functor building an implementation of the weak hash < =============================================================================== < table structure. < ================ --- > The output signature of the functor Weak.Make[20.35]. 7839,7845c6853 < module Make : sig < >> < < < Parameters: < < - H : Hashtbl.HashedType --- > module Make : >> 7846a6855,6856 > functor (H : Hashtbl.HashedType) -> S with type data = H.t > Functor building an implementation of the weak hash table structure. 7849,7852d6858 < << < end < >> < |