summaryrefslogtreecommitdiff
path: root/src/vytree.ml
diff options
context:
space:
mode:
Diffstat (limited to 'src/vytree.ml')
-rw-r--r--src/vytree.ml21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/vytree.ml b/src/vytree.ml
index 05b3088..dec1666 100644
--- a/src/vytree.ml
+++ b/src/vytree.ml
@@ -207,3 +207,24 @@ let move node path position =
let child = get node path in
let node = delete node path in
insert ~position:position ~children:child.children node path child.data
+
+let is_terminal_path node path =
+ try
+ let n = get node path in
+ match (children_of_node n) with
+ | [] -> true
+ | _ -> false
+ with Nonexistent_path -> false
+
+let rec fold_tree_with_path f (p', a) t =
+ let p =
+ match name_of_node t with
+ | "" -> p'
+ | name -> name :: p'
+ in
+ let children = children_of_node t in
+ match children with
+ | [] -> (Util.drop_first p), snd (f (p, a) t)
+ | c -> let res =
+ List.fold_left (fold_tree_with_path f) (f (p, a) t) c in
+ (Util.drop_first p), snd res