aboutsummaryrefslogtreecommitdiffhomepage
path: root/std/Set.bruijn
diff options
context:
space:
mode:
authorMarvin Borner2023-03-07 00:20:52 +0100
committerMarvin Borner2023-03-07 00:22:22 +0100
commitea98cabbe4515bd5248f44214ad870858f1594aa (patch)
tree85b5a52a10dec556729f8c04a73e6b3e415ed07b /std/Set.bruijn
parent9ef10406c067d0a0532d609212a94519af402b87 (diff)
Useful additions
hehe
Diffstat (limited to 'std/Set.bruijn')
-rw-r--r--std/Set.bruijn20
1 files changed, 20 insertions, 0 deletions
diff --git a/std/Set.bruijn b/std/Set.bruijn
new file mode 100644
index 0000000..5f64335
--- /dev/null
+++ b/std/Set.bruijn
@@ -0,0 +1,20 @@
+# MIT License, Copyright (c) 2023 Marvin Borner
+# Set implementation using AVL trees
+# can currently only store Numbers (due to std/Tree/Balanced)
+
+:import std/Tree/Balanced T
+
+# empty set
+empty T.empty ⧗ Set
+
+# adds a number of a set
+add T.insert ⧗ Number → Set → Set
+
+# returns true if a number is in a set
+has? T.has? ⧗ Number → Set → Boolean
+
+# converts a set to a list
+list! T.list! ⧗ Set → (List Number)
+
+# converts a list to a set
+from-list T.from-list ⧗ (List Number) → Set