summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRose Hogenson <rosehogenson@posteo.net>2024-04-27 10:19:54 -0700
committerRose Hogenson <rosehogenson@posteo.net>2024-05-04 15:23:59 -0700
commit8ea9fc2536aa0eb45092ed3654dba19b0c8e7c20 (patch)
tree4c11670239a6722836891f5750098c7582a44011 /tests
parent5737e8430d43b3b5bd448f761cd2f3c35707a174 (diff)
downloadsml-8ea9fc2536aa0eb45092ed3654dba19b0c8e7c20.tar.zst
Implement recursive functions.
Diffstat (limited to 'tests')
-rw-r--r--tests/13-fibonacci.sml7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/13-fibonacci.sml b/tests/13-fibonacci.sml
new file mode 100644
index 0000000..ec89f70
--- /dev/null
+++ b/tests/13-fibonacci.sml
@@ -0,0 +1,7 @@
+val rec fib = fn n =>
+ case n of
+ 0 => 0
+ | 1 => 1
+ | _ => __builtin "add" (fib (__builtin "sub" (n, 1)), fib (__builtin "sub" (n, 2)))
+
+val _ = __builtin "exit" (__builtin "add" (fib 9, 8))