add CCKtree.force

This commit is contained in:
Simon Cruanes 2015-09-04 21:43:11 +02:00
parent 394656660c
commit 118c9154bd
2 changed files with 9 additions and 0 deletions

View file

@ -171,6 +171,10 @@ let bfs ?(pset=set_of_cmp ()) t =
in
bfs pset (FQ.push FQ.empty t)
let rec force t : ([`Nil | `Node of 'a * 'b list] as 'b) = match t() with
| `Nil -> `Nil
| `Node (x, l) -> `Node (x, List.map force l)
let find ?pset f t =
let rec _find_kl f l = match l() with
| `Nil -> None

View file

@ -91,6 +91,11 @@ val dfs : ?pset:'a pset -> 'a t -> [ `Enter of 'a | `Exit of 'a ] klist
val bfs : ?pset:'a pset -> 'a t -> 'a klist
(** Breadth first traversal of the tree *)
val force : 'a t -> ([ `Nil | `Node of 'a * 'b list ] as 'b)
(** [force t] evaluates [t] completely and returns a regular tree
structure
@since NEXT_RELEASE *)
val find : ?pset:'a pset -> ('a -> 'b option) -> 'a t -> 'b option
(** Look for an element that maps to [Some _] *)