mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
Support using ** for exponentiation
This commit is contained in:
parent
13fe66c968
commit
7d25684941
2 changed files with 10 additions and 7 deletions
|
|
@ -42,13 +42,6 @@ let range' i j yield =
|
||||||
[5;4;3] (range' 5 2 |> Sequence.to_list)
|
[5;4;3] (range' 5 2 |> Sequence.to_list)
|
||||||
*)
|
*)
|
||||||
|
|
||||||
module Infix = struct
|
|
||||||
include Pervasives
|
|
||||||
let (--) = range
|
|
||||||
let (--^) = range'
|
|
||||||
end
|
|
||||||
include Infix
|
|
||||||
|
|
||||||
let sign i =
|
let sign i =
|
||||||
if i < 0 then -1
|
if i < 0 then -1
|
||||||
else if i>0 then 1
|
else if i>0 then 1
|
||||||
|
|
@ -77,6 +70,14 @@ let pow a b =
|
||||||
pow 0 1 = 0
|
pow 0 1 = 0
|
||||||
*)
|
*)
|
||||||
|
|
||||||
|
module Infix = struct
|
||||||
|
include Pervasives
|
||||||
|
let (--) = range
|
||||||
|
let (--^) = range'
|
||||||
|
let ( ** ) = pow
|
||||||
|
end
|
||||||
|
include Infix
|
||||||
|
|
||||||
let floor_div a n =
|
let floor_div a n =
|
||||||
if a < 0 && n >= 0 then
|
if a < 0 && n >= 0 then
|
||||||
(a + 1) / n - 1
|
(a + 1) / n - 1
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,8 @@ module Infix : sig
|
||||||
|
|
||||||
val (/) : t -> t -> t (** @since 2.1 *)
|
val (/) : t -> t -> t (** @since 2.1 *)
|
||||||
|
|
||||||
|
val ( ** ) : t -> t -> t
|
||||||
|
|
||||||
val (mod) : t -> t -> t (** @since 2.1 *)
|
val (mod) : t -> t -> t (** @since 2.1 *)
|
||||||
|
|
||||||
val (land) : t -> t -> t (** @since 2.1 *)
|
val (land) : t -> t -> t (** @since 2.1 *)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue