projects
/
tatoo.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
35c32fb
)
Extend the interface with a fold function (over the structure
author
Kim Nguyễn
<kn@lri.fr>
Sat, 9 Mar 2013 10:19:21 +0000
(11:19 +0100)
committer
Kim Nguyễn
<kn@lri.fr>
Sat, 9 Mar 2013 10:19:21 +0000
(11:19 +0100)
of the formula).
src/auto/formula.ml
patch
|
blob
|
history
src/auto/formula.mli
patch
|
blob
|
history
diff --git
a/src/auto/formula.ml
b/src/auto/formula.ml
index
7128ba4
..
097114e
100644
(file)
--- a/
src/auto/formula.ml
+++ b/
src/auto/formula.ml
@@
-14,7
+14,7
@@
(***********************************************************************)
(*
(***********************************************************************)
(*
- Time-stamp: <Last modified on 2013-03-09 11:1
2:54
CET by Kim Nguyen>
+ Time-stamp: <Last modified on 2013-03-09 11:1
6:29
CET by Kim Nguyen>
*)
INCLUDE "utils.ml"
*)
INCLUDE "utils.ml"
@@
-170,4
+170,13
@@
let and_ f1 f2 =
let of_bool = function true -> true_ | false -> false_
let of_bool = function true -> true_ | false -> false_
+let fold f phi acc =
+ let rec loop phi acc =
+ match expr phi with
+ | And (phi1, phi2) | Or(phi1, phi2) ->
+ loop phi2 (loop phi1 (f phi acc))
+ | _ -> f phi acc
+ in
+ loop phi acc
+
end
end
diff --git
a/src/auto/formula.mli
b/src/auto/formula.mli
index
2421d51
..
d708c2d
100644
(file)
--- a/
src/auto/formula.mli
+++ b/
src/auto/formula.mli
@@
-14,7
+14,7
@@
(***********************************************************************)
(*
(***********************************************************************)
(*
- Time-stamp: <Last modified on 2013-03-09 11:1
3:06
CET by Kim Nguyen>
+ Time-stamp: <Last modified on 2013-03-09 11:1
6:45
CET by Kim Nguyen>
*)
module type ATOM =
*)
module type ATOM =
@@
-84,4
+84,7
@@
sig
val of_bool : bool -> t
(** Convert an ocaml Boolean value to a formula *)
val of_bool : bool -> t
(** Convert an ocaml Boolean value to a formula *)
+ val fold : (t -> 'a -> 'a) -> t -> 'a -> 'a
+ (** [fold f phi acc] folds [f] over the formula structure *)
+
end
end