Add 'string-tries-sml/' from commit 'd056e08ce768e014ab409c7f63e8fd0adfc1dff2'

git-subtree-dir: string-tries-sml
git-subtree-mainline: dba78da7ec
git-subtree-split: d056e08ce7
This commit is contained in:
2026-04-24 00:34:11 +01:00
29 changed files with 934828 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
structure BuildExistsBroTree =
struct
fun helpExists (pos, tree, acc) =
if pos = Vector.length WordsList.words then
acc
else
let
val word = Vector.sub (WordsList.words, pos)
val newAcc = BroTree.exists (word, tree)
val acc = newAcc orelse acc
in
helpExists (pos + 1, tree, acc)
end
fun exists (tree) = helpExists (0, tree, true)
fun main () =
let
val endTree = Vector.foldl BroTree.insert BroTree.empty WordsList.words
val startTime = Time.now ()
val wordsExist = exists endTree
val finishTime = Time.now ()
val searchDuration = Time.- (finishTime, startTime)
val searchDuration = Time.toMilliseconds searchDuration
val searchDuration = LargeInt.toString searchDuration ^ "\n"
in
print searchDuration
end
end
val _ = BuildExistsBroTree.main ()