我有这个代码:
cnf.mli
type literal
type clause
type cnf
type l_diff
val l_compare: literal -> literal -> l_diff
Run Code Online (Sandbox Code Playgroud)
cnf.ml(部分)
type l_diff = Same | Negation | Different
Run Code Online (Sandbox Code Playgroud)
checker.ml(部分)
open Cnf
type solution = (literal * bool) list
let rec solve_literal sol l =
match sol with
| [] -> false
| (hl, b)::rs when (l_compare l hl) = Same -> b
| (hl, b)::rs when (l_compare l hl) = Negation -> not b
| _::rs -> solve_literal rs l
Run Code Online (Sandbox Code Playgroud)
这适用于utop使用:
#mod_use …Run Code Online (Sandbox Code Playgroud) ocaml ×1