-
Notifications
You must be signed in to change notification settings - Fork 2
CalcFormulaDepth
George Plotnikov edited this page Feb 7, 2022
·
2 revisions
let rec CalcFormulaDepth formula =
| match formula with
| Var(n) -> 1
| Disj(n, m) -> 1 + CalcFormulaDepth(n) + CalcFormulaDepth(m)
| Conj(n, m) -> 1 + CalcFormulaDepth(n) + CalcFormulaDepth(m)
| Neg(n) -> 1 + CalcFormulaDepth(n)
| Bic(n, m) -> 1 + CalcFormulaDepth(n) + CalcFormulaDepth(m)
| Impl(n, m) -> 1 + CalcFormulaDepth(n) + CalcFormulaDepth(m)
| _ -> 1
This function calculates how many operations are needed to be performed to calculate a formula.
Input:
Formula.Disj(Conj(Var "N", Var "M"), Var "H")
Output:
5
let len = CalcFormulaDepth Formula.Disj(Conj(Var "N", Var "M"), Var "H")
Functions