projects
/
tatoo.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add fold_left/right functions to the set interface (iterate in
[tatoo.git]
/
src
/
ptset.ml
diff --git
a/src/ptset.ml
b/src/ptset.ml
index
87ca2a5
..
08332b3
100644
(file)
--- a/
src/ptset.ml
+++ b/
src/ptset.ml
@@
-289,11
+289,17
@@
struct
| Leaf k -> f k
| Branch (_,_,t0,t1) -> iter f t0; iter f t1
| Leaf k -> f k
| Branch (_,_,t0,t1) -> iter f t0; iter f t1
- let rec fold f s accu = match s.Node.node with
+ let rec fold
_left
f s accu = match s.Node.node with
| Empty -> accu
| Leaf k -> f k accu
| Empty -> accu
| Leaf k -> f k accu
- | Branch (_,_,t0,t1) -> fold
f t1 (fold
f t0 accu)
+ | Branch (_,_,t0,t1) -> fold
_left f t1 (fold_left
f t0 accu)
+ let rec fold_right f s accu = match s.Node.node with
+ | Empty -> accu
+ | Leaf k -> f k accu
+ | Branch (_,_,t0,t1) -> fold_right f t0 (fold_right f t1 accu)
+
+ let fold f s accu = fold_left f s accu
let rec for_all p n = match n.Node.node with
| Empty -> true
let rec for_all p n = match n.Node.node with
| Empty -> true