mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-11-07 06:33:39 +01:00
32 lines
483 B
OCaml
32 lines
483 B
OCaml
type t =
|
|
| Pos
|
|
| Neg
|
|
|
|
let of_nperm nperm =
|
|
if (nperm land 1) = 1 then Neg
|
|
else Pos
|
|
|
|
let to_nperm = function
|
|
| Pos -> 0
|
|
| Neg -> 1
|
|
|
|
let add t t' =
|
|
match t, t' with
|
|
| Pos, Pos
|
|
| Neg, Neg -> Pos
|
|
| Pos, Neg
|
|
| Neg, Pos -> Neg
|
|
|
|
let neg = function
|
|
| Pos -> Neg
|
|
| Neg -> Pos
|
|
|
|
let add_nperm phase = function
|
|
| 0 -> phase
|
|
| nperm -> add phase (of_nperm nperm)
|
|
|
|
let pp ppf = function
|
|
| Pos -> Format.fprintf ppf "@[<h>+1@]"
|
|
| Neg -> Format.fprintf ppf "@[<h>-1@]"
|
|
|