aboutsummaryrefslogtreecommitdiff
path: root/example/fizzbuzz.slang
diff options
context:
space:
mode:
Diffstat (limited to 'example/fizzbuzz.slang')
-rw-r--r--example/fizzbuzz.slang16
1 files changed, 16 insertions, 0 deletions
diff --git a/example/fizzbuzz.slang b/example/fizzbuzz.slang
new file mode 100644
index 0000000..653c180
--- /dev/null
+++ b/example/fizzbuzz.slang
@@ -0,0 +1,16 @@
+1 i $
+
+§ incr dup @ 1 + swp $ ;
+§ withinBounds @ 100 < ;
+
+§ fizz? @ 3 % 0 = ;
+§ buzz? @ 5 % 0 = ;
+
+§ fizzbuzz_or_fizz buzz? if fizzbuzz then fizz else . pop ;
+§ buzz_or_print dup buzz? if buzz then @ else . pop ;
+
+§ branch dup fizz? if fizzbuzz_or_fizz then buzz_or_print else ;
+
+§ loop i withinBounds if i branch i incr loop then else ;
+
+loop