add 'PersistentVector.countDepth' function, which is meant to count the depth, and is to be used for deletion

This commit is contained in:
2026-01-17 22:51:06 +00:00
parent 4280f580a2
commit b84713a98e

View File

@@ -529,6 +529,13 @@ struct
LEAF (items, sizes) LEAF (items, sizes)
end end
fun countDepthLoop (counter, tree) =
case tree of
BRANCH (nodes, _) => countDepthLoop (counter + 1, Vector.sub (nodes, 0))
| LEAF (_, _) => counter + 1
fun countDepth tree = countDepthLoop (0, tree)
(* functions only for testing *) (* functions only for testing *)
fun fromListLoop (lst, acc) = fun fromListLoop (lst, acc) =
case lst of case lst of