2014-10-25 21:24:21 +02:00
|
|
|
open Core.Std;;
|
2014-08-26 15:31:16 +02:00
|
|
|
|
|
|
|
(*
|
|
|
|
Type for bits
|
|
|
|
==============
|
|
|
|
|
|
|
|
Zero | One
|
|
|
|
|
|
|
|
*)
|
|
|
|
|
2014-10-26 17:29:11 +01:00
|
|
|
type t =
|
|
|
|
| One
|
|
|
|
| Zero
|
2014-10-25 21:24:21 +02:00
|
|
|
with sexp
|
2014-08-26 15:31:16 +02:00
|
|
|
|
|
|
|
let to_string = function
|
|
|
|
| Zero -> "0"
|
|
|
|
| One -> "1"
|
|
|
|
;;
|
|
|
|
|
|
|
|
let and_operator a b =
|
|
|
|
match a, b with
|
|
|
|
| Zero, _ -> Zero
|
|
|
|
| _, Zero -> Zero
|
|
|
|
| _, _ -> One
|
|
|
|
;;
|
|
|
|
|
|
|
|
let or_operator a b =
|
|
|
|
match a, b with
|
|
|
|
| One, _ -> One
|
|
|
|
| _, One -> One
|
|
|
|
| _, _ -> Zero
|
|
|
|
;;
|
|
|
|
|
|
|
|
let xor_operator a b =
|
|
|
|
match a, b with
|
|
|
|
| One, Zero -> One
|
|
|
|
| Zero, One -> One
|
|
|
|
| _, _ -> Zero
|
|
|
|
;;
|
|
|
|
|
|
|
|
let not_operator = function
|
|
|
|
| One -> Zero
|
|
|
|
| Zero -> One
|
|
|
|
;;
|
|
|
|
|