add utility function to insert from a list into a set

This commit is contained in:
2025-10-10 03:29:52 +01:00
parent 88eb30dbf2
commit 108a30ea79

View File

@@ -109,6 +109,16 @@ struct
BRANCH (l, newKey, newVal, r)
| LEAF => BRANCH (LEAF, newKey, newVal, LEAF)
fun addFromList (lst, tree) =
case lst of
[] => tree
| (k, v) :: tl =>
let
val tree = insertOrReplace (k, v, tree)
in
addFromList (tl, tree)
end
fun getOrDefault (findKey, tree, default) =
case tree of
BRANCH (l, curKey, curVal, r) =>