Skip to content
This repository was archived by the owner on Feb 6, 2025. It is now read-only.

Commit 966c128

Browse files
committed
commentaires après
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4082 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1 parent 8cd61ac commit 966c128

File tree

15 files changed

+355
-357
lines changed

15 files changed

+355
-357
lines changed

stdlib/arg.mli

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,21 @@
3737
two arguments)
3838
*)
3939

40-
(** The concrete type describing the behavior associated
41-
with a keyword. *)
4240
type spec =
43-
| Unit of (unit -> unit) (** Call the function with unit argument *)
41+
Unit of (unit -> unit) (** Call the function with unit argument *)
4442
| Set of bool ref (** Set the reference to true *)
4543
| Clear of bool ref (** Set the reference to false *)
4644
| String of (string -> unit) (** Call the function with a string argument *)
4745
| Int of (int -> unit) (** Call the function with an int argument *)
4846
| Float of (float -> unit) (** Call the function with a float argument *)
49-
| Rest of (string -> unit) (** Stop interpreting keywords and call the
50-
function with each remaining argument *)
47+
| Rest of (string -> unit) (** Stop interpreting keywords and call the
48+
function with each remaining argument *)
49+
50+
(** The concrete type describing the behavior associated
51+
with a keyword. *)
5152

53+
val parse :
54+
(string * spec * string) list -> (string -> unit) -> string -> unit
5255
(** [Arg.parse speclist anonfun usage_msg] parses the command line.
5356
[speclist] is a list of triples [(key, spec, doc)].
5457
[key] is the option keyword, it must start with a ['-'] character.
@@ -73,19 +76,17 @@ type spec =
7376
the program. You can override this behaviour by specifying your
7477
own [-help] and [--help] options in [speclist].
7578
*)
76-
val parse : (string * spec * string) list ->
77-
(string -> unit) -> string -> unit
7879

80+
exception Bad of string
7981
(** Functions in [spec] or [anonfun] can raise [Arg.Bad] with an error
8082
message to reject invalid arguments. *)
81-
exception Bad of string
8283

84+
val usage : (string * spec * string) list -> string -> unit
8385
(** [Arg.usage speclist usage_msg] prints an error message including
8486
the list of valid options. This is the same message that
8587
{!Arg.parse} prints in case of error.
8688
[speclist] and [usage_msg] are the same as for [Arg.parse]. *)
87-
val usage : (string * spec * string) list -> string -> unit
8889

90+
val current : int ref
8991
(** Position (in {!Sys.argv}) of the argument being processed. You can
9092
change this value, e.g. to force {!Arg.parse} to skip some arguments.*)
91-
val current : int ref;;

stdlib/array.mli

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,27 @@
1414

1515
(** Array operations. *)
1616

17-
(** Return the length (number of elements) of the given array. *)
1817
external length : 'a array -> int = "%array_length"
18+
(** Return the length (number of elements) of the given array. *)
1919

20+
external get : 'a array -> int -> 'a = "%array_safe_get"
2021
(** [Array.get a n] returns the element number [n] of array [a].
2122
The first element has number 0.
2223
The last element has number [Array.length a - 1].
2324
2425
Raise [Invalid_argument "Array.get"] if [n] is outside the range
2526
0 to [(Array.length a - 1)].
2627
You can also write [a.(n)] instead of [Array.get a n]. *)
27-
external get: 'a array -> int -> 'a = "%array_safe_get"
2828

29+
external set : 'a array -> int -> 'a -> unit = "%array_safe_set"
2930
(** [Array.set a n x] modifies array [a] in place, replacing
3031
element number [n] with [x].
3132
3233
Raise [Invalid_argument "Array.set"] if [n] is outside the range
3334
0 to [Array.length a - 1].
3435
You can also write [a.(n) <- x] instead of [Array.set a n x]. *)
35-
external set: 'a array -> int -> 'a -> unit = "%array_safe_set"
3636

37+
external make : int -> 'a -> 'a array = "make_vect"
3738
(** [Array.make n x] returns a fresh array of length [n],
3839
initialized with [x].
3940
All the elements of this new array are initially
@@ -45,17 +46,17 @@ external set: 'a array -> int -> 'a -> unit = "%array_safe_set"
4546
Raise [Invalid_argument] if [n < 0] or [n > Sys.max_array_length].
4647
If the value of [x] is a floating-point number, then the maximum
4748
size is only [Sys.max_array_length / 2].*)
48-
external make: int -> 'a -> 'a array = "make_vect"
4949

50+
external create : int -> 'a -> 'a array = "make_vect"
5051
(** @deprecated [Array.create] is an alias for {!Array.make}. *)
51-
external create: int -> 'a -> 'a array = "make_vect"
5252

53+
val init : int -> (int -> 'a) -> 'a array
5354
(** [Array.init n f] returns a fresh array of length [n],
5455
with element number [i] initialized to the result of [f i].
5556
In other terms, [Array.init n f] tabulates the results of [f]
5657
applied to the integers [0] to [n-1]. *)
57-
val init: int -> (int -> 'a) -> 'a array
5858

59+
val make_matrix : int -> int -> 'a -> 'a array array
5960
(** [Array.make_matrix dimx dimy e] returns a two-dimensional array
6061
(an array of arrays) with first dimension [dimx] and
6162
second dimension [dimy]. All the elements of this new matrix
@@ -67,38 +68,38 @@ val init: int -> (int -> 'a) -> 'a array
6768
greater than [Sys.max_array_length].
6869
If the value of [e] is a floating-point number, then the maximum
6970
size is only [Sys.max_array_length / 2]. *)
70-
val make_matrix: int -> int -> 'a -> 'a array array
7171

72+
val create_matrix : int -> int -> 'a -> 'a array array
7273
(** @deprecated [Array.create_matrix] is an alias for {!Array.make_matrix}. *)
73-
val create_matrix: int -> int -> 'a -> 'a array array
7474

75+
val append : 'a array -> 'a array -> 'a array
7576
(** [Array.append v1 v2] returns a fresh array containing the
7677
concatenation of the arrays [v1] and [v2]. *)
77-
val append: 'a array -> 'a array -> 'a array
7878

79+
val concat : 'a array list -> 'a array
7980
(** Same as [Array.append], but catenates a list of arrays. *)
80-
val concat: 'a array list -> 'a array
8181

82+
val sub : 'a array -> int -> int -> 'a array
8283
(** [Array.sub a start len] returns a fresh array of length [len],
8384
containing the elements number [start] to [start + len - 1]
8485
of array [a].
8586
8687
Raise [Invalid_argument "Array.sub"] if [start] and [len] do not
8788
designate a valid subarray of [a]; that is, if
8889
[start < 0], or [len < 0], or [start + len > Array.length a]. *)
89-
val sub: 'a array -> int -> int -> 'a array
9090

91+
val copy : 'a array -> 'a array
9192
(** [Array.copy a] returns a copy of [a], that is, a fresh array
9293
containing the same elements as [a]. *)
93-
val copy: 'a array -> 'a array
9494

95+
val fill : 'a array -> int -> int -> 'a -> unit
9596
(** [Array.fill a ofs len x] modifies the array [a] in place,
9697
storing [x] in elements number [ofs] to [ofs + len - 1].
9798
9899
Raise [Invalid_argument "Array.fill"] if [ofs] and [len] do not
99100
designate a valid subarray of [a]. *)
100-
val fill: 'a array -> int -> int -> 'a -> unit
101101

102+
val blit : 'a array -> int -> 'a array -> int -> int -> unit
102103
(** [Array.blit v1 o1 v2 o2 len] copies [len] elements
103104
from array [v1], starting at element number [o1], to array [v2],
104105
starting at element number [o2]. It works correctly even if
@@ -108,49 +109,49 @@ val fill: 'a array -> int -> int -> 'a -> unit
108109
Raise [Invalid_argument "Array.blit"] if [o1] and [len] do not
109110
designate a valid subarray of [v1], or if [o2] and [len] do not
110111
designate a valid subarray of [v2]. *)
111-
val blit: 'a array -> int -> 'a array -> int -> int -> unit
112112

113+
val to_list : 'a array -> 'a list
113114
(** [Array.to_list a] returns the list of all the elements of [a]. *)
114-
val to_list: 'a array -> 'a list
115115

116+
val of_list : 'a list -> 'a array
116117
(** [Array.of_list l] returns a fresh array containing the elements
117118
of [l]. *)
118-
val of_list: 'a list -> 'a array
119119

120+
val iter : ('a -> unit) -> 'a array -> unit
120121
(** [Array.iter f a] applies function [f] in turn to all
121122
the elements of [a]. It is equivalent to
122123
[f a.(0); f a.(1); ...; f a.(Array.length a - 1); ()]. *)
123-
val iter: ('a -> unit) -> 'a array -> unit
124124

125+
val map : ('a -> 'b) -> 'a array -> 'b array
125126
(** [Array.map f a] applies function [f] to all the elements of [a],
126127
and builds an array with the results returned by [f]:
127128
[[| f a.(0); f a.(1); ...; f a.(Array.length a - 1) |]]. *)
128-
val map: ('a -> 'b) -> 'a array -> 'b array
129129

130+
val iteri : (int -> 'a -> unit) -> 'a array -> unit
130131
(** Same as {!Array.iter}, but the
131132
function is applied to the index of the element as first argument,
132133
and the element itself as second argument. *)
133-
val iteri: (int -> 'a -> unit) -> 'a array -> unit
134134

135+
val mapi : (int -> 'a -> 'b) -> 'a array -> 'b array
135136
(** Same as {!Array.map}, but the
136137
function is applied to the index of the element as first argument,
137138
and the element itself as second argument. *)
138-
val mapi: (int -> 'a -> 'b) -> 'a array -> 'b array
139139

140+
val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b array -> 'a
140141
(** [Array.fold_left f x a] computes
141142
[f (... (f (f x a.(0)) a.(1)) ...) a.(n-1)],
142143
where [n] is the length of the array [a]. *)
143-
val fold_left: ('a -> 'b -> 'a) -> 'a -> 'b array -> 'a
144144

145+
val fold_right : ('b -> 'a -> 'a) -> 'b array -> 'a -> 'a
145146
(** [Array.fold_right f a x] computes
146147
[f a.(0) (f a.(1) ( ... (f a.(n-1) x) ...))],
147148
where [n] is the length of the array [a]. *)
148-
val fold_right: ('b -> 'a -> 'a) -> 'b array -> 'a -> 'a
149149

150150

151151
(** {2 Sorting} *)
152152

153153

154+
val sort : ('a -> 'a -> int) -> 'a array -> unit
154155
(** Sort an array in increasing order according to a comparison
155156
function. The comparison function must return 0 if its arguments
156157
compare as equal, a positive integer if the first is greater,
@@ -161,22 +162,20 @@ val fold_right: ('b -> 'a -> 'a) -> 'b array -> 'a -> 'a
161162
[Array.sort] is guaranteed to run in constant heap space
162163
and logarithmic stack space.
163164
164-
165165
The current implementation uses Heap Sort. It runs in constant
166166
stack space.
167167
*)
168-
val sort : ('a -> 'a -> int) -> 'a array -> unit;;
169168

169+
val stable_sort : ('a -> 'a -> int) -> 'a array -> unit
170170
(** Same as {!Array.sort}, but the sorting algorithm is stable and
171171
not guaranteed to use a fixed amount of heap memory.
172172
The current implementation is Merge Sort. It uses [n/2]
173173
words of heap space, where [n] is the length of the array.
174174
It is faster than the current implementation of {!Array.sort}.
175175
*)
176-
val stable_sort : ('a -> 'a -> int) -> 'a array -> unit;;
177176

178177
(**/**)
179178
(** {2 Undocumented functions} *)
180179

181-
external unsafe_get: 'a array -> int -> 'a = "%array_unsafe_get"
182-
external unsafe_set: 'a array -> int -> 'a -> unit = "%array_unsafe_set"
180+
external unsafe_get : 'a array -> int -> 'a = "%array_unsafe_get"
181+
external unsafe_set : 'a array -> int -> 'a -> unit = "%array_unsafe_set"

0 commit comments

Comments
 (0)