From 7a4a99a4086066f1fbfdf9b348e9c7df04c636e9 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Wed, 4 Sep 2024 08:16:56 +0100 Subject: [PATCH] add 'fromList' convenience function --- src/string-set.sml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/string-set.sml b/src/string-set.sml index 2c9177a..218550a 100644 --- a/src/string-set.sml +++ b/src/string-set.sml @@ -420,5 +420,11 @@ struct fun addList (lst, trie) = List.foldl helpAddList trie lst - val trie = let val trie = fromString "hello" in addList (["bye"], trie) end + fun fromList (hd :: tl) = + let val trie = fromString hd + in addList (tl, trie) + end + | fromList ([]) = raise Empty + + val trie = fromList ["hello"] end