Data and Math
vtree
Binary search trees and tries, built from shapes that point at each other.
Released v1.0.0 · 2026-09-28use "stdlib/tree.ven"
root = nothing
root = bst_insert(root, 5)
root = bst_insert(root, 2)
print bst_in_order(root)
Reference (12 functions)
API reference
bst_insert(node, value)
Inserts value into the binary search tree rooted at node.
root = nothing
root = bst_insert(root, 5)
root = bst_insert(root, 2)
bst_in_order(root)bst_contains(node, value)
Tests whether value exists anywhere in the tree rooted at node.
root = nothing
root = bst_insert(root, 5)
root = bst_insert(root, 2)
bst_contains(root, 2)bst_in_order(node)
Gives back every value in the tree rooted at node, sorted ascending.
root = nothing
root = bst_insert(root, 5)
root = bst_insert(root, 1)
root = bst_insert(root, 3)
bst_in_order(root)bst_min_node(node)
root = nothing
root = bst_insert(root, 5)
root = bst_insert(root, 2)
root = bst_insert(root, 8)
bst_min_node(root).valuebst_remove(node, value)
Removes value from the tree rooted at node, if present.
root = nothing
root = bst_insert(root, 5)
root = bst_insert(root, 2)
root = bst_insert(root, 8)
root = bst_remove(root, 5)
bst_in_order(root)bst_height(node)
Gives back the height of the tree rooted at node.
root = nothing
root = bst_insert(root, 5)
root = bst_insert(root, 2)
root = bst_insert(root, 8)
bst_height(root)trie_insert(root, word)
Inserts word into the trie rooted at root.
t = trie_new()
trie_insert(t, "cat")
trie_contains(t, "cat")trie_find_node(root, prefix)
t = trie_new()
trie_insert(t, "cat")
trie_find_node(t, "ca") == nothingtrie_contains(root, word)
Tests whether word was inserted into the trie rooted at root.
t = trie_new()
trie_insert(t, "cat")
trie_contains(t, "ca")trie_collect_words(node, prefix, result)
Collects every complete word reachable from node into result.
t = trie_new()
trie_insert(t, "cat")
trie_insert(t, "car")
trie_collect_words(t, "", [])trie_words_with_prefix(root, prefix)
Gives back every inserted word that starts with prefix.
t = trie_new()
trie_insert(t, "cat")
trie_insert(t, "car")
trie_insert(t, "dog")
trie_words_with_prefix(t, "ca")