From b84713a98e3bfc18708ad3124b027c072833f547 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Sat, 17 Jan 2026 22:51:06 +0000 Subject: [PATCH] add 'PersistentVector.countDepth' function, which is meant to count the depth, and is to be used for deletion --- fcore/persistent-vector.sml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fcore/persistent-vector.sml b/fcore/persistent-vector.sml index 74f7840..11aca07 100644 --- a/fcore/persistent-vector.sml +++ b/fcore/persistent-vector.sml @@ -529,6 +529,13 @@ struct LEAF (items, sizes) 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 *) fun fromListLoop (lst, acc) = case lst of