bool.mlw 759 Bytes
Newer Older
1

2 3 4 5
(** {1 Booleans} *)

(** {2 Basic theory of Booleans} *)

6
module Bool
7

8
  let function andb (x y : bool) : bool =
9 10 11
    match x with
    | True -> y
    | False -> False
12 13
    end

14
  let function orb (x y : bool) : bool =
15 16 17
    match x with
    | False -> y
    | True -> True
18 19
    end

20
  let function notb (x : bool) : bool =
21 22 23 24 25
    match x with
    | False -> True
    | True  -> False
    end

26
  let function xorb (x y : bool) : bool =
27 28 29 30 31
    match x with
    | False -> y
    | True -> notb y
    end

32
  let function implb (x y : bool) : bool =
33 34 35
    match x with
    | False -> True
    | True -> y
MARCHE Claude's avatar
MARCHE Claude committed
36 37
    end

38 39
end

40 41
(** {2 Operator if-then-else} *)

42
module Ite
43

44
  let function ite (b:bool) (x y : 'a) : 'a =
45 46 47 48 49 50
    match b with
    | True  -> x
    | False -> y
    end

end