小编SHI*_*485的帖子

使用依赖的变体

我有这个代码:

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

0
推荐指数
1
解决办法
78
查看次数

标签 统计

ocaml ×1