Module Tablecloth.Bool Functions for working with boolean (true or false) values.
Functions for working with boolean values.
Booleans in OCaml / Reason are represented by the true and false literals.
Whilst a bool isnt a variant, you will get warnings if you haven't exhaustively pattern match on them:
let bool = false
let string =
match bool with
| false -> "false"
(*
Warning 8: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
true
*) Createval fromInt : int -> bool option Convert an Int into a Bool .
Examples
Bool.fromInt 0 = Some falseBool.fromInt 1 = Some trueBool.fromInt 8 = NoneBool.fromInt (-3) = Noneval from_int : int -> bool option val fromString : string -> bool option Convert a String into a Bool .
Examples
Bool.fromString "true" = Some trueBool.fromString "false" = Some falseBool.fromString "True" = NoneBool.fromString "False" = NoneBool.fromString "0" = NoneBool.fromString "1" = NoneBool.fromString "Not even close" = Noneval from_string : string -> bool option Basic operationsval (&&) : bool -> bool -> boolThe lazy logical AND operator.
Returns true if both of its operands evaluate to true.
If the 'left' operand evaluates to false, the 'right' operand is not evaluated.
Examples
Bool.(true && true) = trueBool.(true && false) = falseBool.(false && true) = falseBool.(false && false) = falseval (||) : bool -> bool -> boolThe lazy logical OR operator.
Returns true if one of its operands evaluates to true.
If the 'left' operand evaluates to true, the 'right' operand is not evaluated.
Examples
Bool.(true || true) = trueBool.(true || false) = trueBool.(false || true) = trueBool.(false || false) = falseval xor : bool -> bool -> boolThe exclusive or operator.
Returns true if exactly one of its operands is true.
Examples
Bool.xor true true = falseBool.xor true false = trueBool.xor false true = trueBool.xor false false = falseNegate a bool.
Examples
Bool.not false = trueBool.not true = false Convertval toString : bool -> stringConvert a bool to a String
Examples
Bool.toString true = "true"Bool.toString false = "false"val to_string : bool -> stringConvert a bool to an Int .
Examples
Bool.toInt true = 1Bool.toInt false = 0 Compareval equal : bool -> bool -> boolTest for the equality of two bool values.
Examples
Bool.equal true true = trueBool.equal false false = trueBool.equal false true = falseval compare : bool -> bool -> intCompare two boolean values
Examples
Bool.compare true false = 1Bool.compare false true = -1Bool.compare true true = 0Bool.compare false false = 0