diff options
author | Adrian Kummerlaender | 2017-04-17 13:56:14 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2017-04-17 13:56:14 +0200 |
commit | 399faa1f97390215628d245f006610a9586ff1e9 (patch) | |
tree | 873d0510b2afeaee4e06b06f71ec0cb388fdaa35 | |
parent | 20b916b3c90828028c4e981dea06696c23998cf1 (diff) | |
download | slang-399faa1f97390215628d245f006610a9586ff1e9.tar slang-399faa1f97390215628d245f006610a9586ff1e9.tar.gz slang-399faa1f97390215628d245f006610a9586ff1e9.tar.bz2 slang-399faa1f97390215628d245f006610a9586ff1e9.tar.lz slang-399faa1f97390215628d245f006610a9586ff1e9.tar.xz slang-399faa1f97390215628d245f006610a9586ff1e9.tar.zst slang-399faa1f97390215628d245f006610a9586ff1e9.zip |
Add some example programs
-rw-r--r-- | example/countup.slang | 9 | ||||
-rw-r--r-- | example/fizzbuzz.slang | 16 |
2 files changed, 25 insertions, 0 deletions
diff --git a/example/countup.slang b/example/countup.slang new file mode 100644 index 0000000..69e71db --- /dev/null +++ b/example/countup.slang @@ -0,0 +1,9 @@ +1 i $ + +§ incr dup @ 1 + swp $ ; +§ print @ . pop ; +§ withinBounds @ 10 < ; + +§ loop i withinBounds if i print i incr loop then else ; + +loop 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 |