Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (* booleanExpression.ml *)
- type 'canonical boolean_expression = [
- `Variable of int |
- `Not of 'canonical boolean_expression |
- `And of 'canonical boolean_expression list |
- `Or of 'canonical boolean_expression list
- ];;
- let rec string_of_boolean_expression e =
- let string_of_boolean_expression_list o l =
- match l with
- | [] -> ""
- | h :: t ->
- let rec loop l s =
- match l with
- | [] -> s
- | h :: t ->
- loop t (s ^ o ^ (string_of_boolean_expression h))
- in "(" ^ (string_of_boolean_expression h) ^ (loop t "") ^ ")"
- in
- match e with
- | `Variable( i ) -> string_of_int i
- | `Not( sub_e ) -> "¬" ^ (string_of_boolean_expression sub_e)
- | `And l -> string_of_boolean_expression_list "∧" l
- | `Or l -> string_of_boolean_expression_list "∨" l
- ;;
- type not_canonical_boolean_expression = [`Not_canonical] boolean_expression;;
- (* booleanExpression.mli *)
- type not_canonical_boolean_expression = [
- `Variable of int |
- `Not of not_canonical_boolean_expression |
- `And of not_canonical_boolean_expression list |
- `Or of not_canonical_boolean_expression list
- ];;
- val string_of_boolean_expression : not_canonical_boolean_expression -> string
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement