aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorGravatar Moon Flower <moon@coffin.ir> 2025-02-28 01:50:25 +0330
committerGravatar Moon Flower <moon@coffin.ir> 2025-02-28 01:50:25 +0330
commitf7a08d4db77eaef1f6685c3fb263bb1cb1376deb (patch)
treec6fb20ba555421bf5fc483717810ba2234ce235b /main.c
parentDecently performant double-linked two-way linked list implementation (diff)
Added a (rather useless) profiler (and also linked list speed optimizations)
Diffstat (limited to 'main.c')
-rw-r--r--main.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/main.c b/main.c
index 58c28dd..c59984f 100644
--- a/main.c
+++ b/main.c
@@ -2,17 +2,30 @@
#include "moonshine.h"
-datatype(binarytree, ((leaf, int), (node, binarytree *, int, binarytree *) ));
+const enum { test_datatype, test_linkedlist } current_test = test_linkedlist;
int main() {
- const auto tree = instance(binarytree, leaf, 3);
+ if (current_test == test_datatype) {
+ datatype(binarytree, ((leaf, int), (node, binarytree *, int, binarytree *) ));
+ const auto tree = instance(binarytree, leaf, 3);
- print(&tree);
+ print(&tree);
- match(tree) {
- of(leaf, v) print("Leafy ", v);
- of(node, _, v, _) print("Nodey ", v);
- other() print("Idk man");
+ match(tree) {
+ of(leaf, v) print("Leafy ", v);
+ of(node, _, v, _) print("Nodey ", v);
+ other() print("Idk man");
+ }
+ } else if (current_test == test_linkedlist) {
+ const auto ll = create_linkedlist();
+
+ for (u8 i = 0; i < 100; i++) push_linkedlist(ll, (var) i);
+
+ print((u8) index_to_ptr(ll, 12)->data);
+ }
+
+ else {
+ print("Unknown test.");
}
return 0;