Prelude.RoseN-ary (Rose) trees.
The type of Rose trees.
val unit : 'a -> 'a t(unit v) is the unit tree carrying value v and no children.
val unfold : ('a -> 'b * 'a list) -> 'a -> 'b t(unfold f seed) builds a t by recusively expanding (f seed).
The recursion is terminated when (snd << f) = [].
This example builds a tree isomorphic to the directory structure rooted at dir:
let f d =
Filename.(basename d, default [||] Sys.readdir d |> Array.to_list |> map (concat d)) in
unfold f dir val random : (unit -> 'a) -> unit -> 'a t(random r ()) is a random rose tree; each element is given by (r ()).
val fold : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'aval flatten : 'a t -> 'a listflatten does a pre-order traversal of a t and returns the values in a list.
val draw : ('a -> string) -> 'a t -> string list(draw f t) "returns a neat two dimentional drawing of t; shamelessly ripped of from Haskell 'containers' package."
Each element of the list is a line of output; the list is suitable to pass to (iter print_endline).