aboutsummaryrefslogtreecommitdiffhomepage
path: root/samples/rosetta/ackermann_function.bruijn
diff options
context:
space:
mode:
authorMarvin Borner2024-03-30 16:54:14 +0100
committerMarvin Borner2024-03-30 16:54:14 +0100
commit2e0a67b6219052b57a9ca5db666038c31ea0cec9 (patch)
tree7353297ad0ec436e3d7c8f6566416c8a150f0897 /samples/rosetta/ackermann_function.bruijn
parentda026dcd2f4a2c35dc59afe6dce33c5aaa6df84f (diff)
Adds tests for samples
Diffstat (limited to 'samples/rosetta/ackermann_function.bruijn')
-rw-r--r--samples/rosetta/ackermann_function.bruijn17
1 files changed, 17 insertions, 0 deletions
diff --git a/samples/rosetta/ackermann_function.bruijn b/samples/rosetta/ackermann_function.bruijn
new file mode 100644
index 0000000..c0689f1
--- /dev/null
+++ b/samples/rosetta/ackermann_function.bruijn
@@ -0,0 +1,17 @@
+:import std/Combinator .
+:import std/Number/Unary U
+:import std/Math .
+
+# unary ackermann
+ackermann-unary [0 [[U.inc 0 1 (+1u)]] U.inc]
+
+:test (ackermann-unary (+0u) (+0u)) ((+1u))
+:test (ackermann-unary (+3u) (+4u)) ((+125u))
+
+# ternary ackermann (lower space complexity)
+ackermann-ternary y [[[=?1 ++0 (=?0 (2 --1 (+1)) (2 --1 (2 1 --0)))]]]
+
+:test ((ackermann-ternary (+0) (+0)) =? (+1)) ([[1]])
+:test ((ackermann-ternary (+3) (+4)) =? (+125)) ([[1]])
+
+main [[0]]