mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
implement CCInt.sign using CCInt.compare and add more doc
This commit is contained in:
parent
eaa421c62d
commit
b06155f05b
2 changed files with 3 additions and 5 deletions
|
|
@ -71,10 +71,7 @@ let range' i j yield =
|
||||||
[5;4;3] (range' 5 2 |> Iter.to_list)
|
[5;4;3] (range' 5 2 |> Iter.to_list)
|
||||||
*)
|
*)
|
||||||
|
|
||||||
let sign i =
|
let sign i = compare i 0
|
||||||
if i < 0 then -1
|
|
||||||
else if i>0 then 1
|
|
||||||
else 0
|
|
||||||
|
|
||||||
let neg i = -i
|
let neg i = -i
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,8 @@ val hash : t -> int
|
||||||
(** [hash x] computes the hash of [x]. *)
|
(** [hash x] computes the hash of [x]. *)
|
||||||
|
|
||||||
val sign : t -> int
|
val sign : t -> int
|
||||||
(** [sign x] is one of [-1, 0, 1]. *)
|
(** [sign x] return [0] if [x = 0], [-1] if [x < 0] and [1] if [x > 0].
|
||||||
|
Same as [compare x 0].*)
|
||||||
|
|
||||||
val neg : t -> t
|
val neg : t -> t
|
||||||
(** [neg x] is [- x].
|
(** [neg x] is [- x].
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue