add utility function to insert from a list into a set
This commit is contained in:
@@ -109,6 +109,16 @@ struct
|
|||||||
BRANCH (l, newKey, newVal, r)
|
BRANCH (l, newKey, newVal, r)
|
||||||
| LEAF => BRANCH (LEAF, newKey, newVal, LEAF)
|
| 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) =
|
fun getOrDefault (findKey, tree, default) =
|
||||||
case tree of
|
case tree of
|
||||||
BRANCH (l, curKey, curVal, r) =>
|
BRANCH (l, curKey, curVal, r) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user