Support using ** for exponentiation

This commit is contained in:
Metin Akat 2018-08-31 12:21:54 +03:00 committed by Simon Cruanes
parent 13fe66c968
commit 7d25684941
2 changed files with 10 additions and 7 deletions

View file

@ -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

View file

@ -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 *)