summaryrefslogtreecommitdiff
path: root/examples/fib.ash
diff options
context:
space:
mode:
authorSuleyman Farajli <suleyman@farajli.net>2025-01-07 02:24:19 +0400
committerSuleyman Farajli <suleyman@farajli.net>2025-01-07 02:24:19 +0400
commit180b6ab7c204ddf3a8aa2b9b022085e6a96ff99a (patch)
treeafb0144af0ba75d516e100d1fc6fa0c309620c0e /examples/fib.ash
parentc9090da5bd98c418f71f9110c6c3d82f2f7d37ee (diff)
program name changed to 'ash'
Diffstat (limited to 'examples/fib.ash')
-rw-r--r--examples/fib.ash16
1 files changed, 16 insertions, 0 deletions
diff --git a/examples/fib.ash b/examples/fib.ash
new file mode 100644
index 0000000..bf2b90d
--- /dev/null
+++ b/examples/fib.ash
@@ -0,0 +1,16 @@
+# Print out given number of elements in the Fibonacci sequence, 46 is the max value
+define fib
+ var lim push lim
+ var a 1 push a
+ var b 1 push b
+ pull lim while dup 0 > do
+ pull a dump
+ pull b dup
+ pull a
+ + push b
+ push a
+ 1 -
+ done
+end
+
+10 fib