| 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
- | 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