summaryrefslogtreecommitdiff
path: root/examples/fizzbuzz.dumb
diff options
context:
space:
mode:
authorMatthew Hall <hallmatthew314@gmail.com>2023-02-22 22:23:35 +1300
committerMatthew Hall <hallmatthew314@gmail.com>2023-02-22 22:24:29 +1300
commitbad32a12573bf14968746ea9ad0f6c4f20b50cf1 (patch)
tree26ce098f30f054b2f2a742d2c06b857951ea68db /examples/fizzbuzz.dumb
parent0bde837174fcb9c17cb3adbf6bc3c7407cab10df (diff)
Re-work program structure, MAIN entrypoint + only PROC definitions
Diffstat (limited to 'examples/fizzbuzz.dumb')
-rw-r--r--examples/fizzbuzz.dumb27
1 files changed, 14 insertions, 13 deletions
diff --git a/examples/fizzbuzz.dumb b/examples/fizzbuzz.dumb
index 2ba6033..f9aa648 100644
--- a/examples/fizzbuzz.dumb
+++ b/examples/fizzbuzz.dumb
@@ -1,14 +1,15 @@
-''' bottom of the stack is the incrementing value, starts at 1 '''
-1
-''' while the incrementing value is <= 100 '''
-WHILE 100 OVER <= DO
- ''' push string "Buzz" if inc. is divisible by 5, else an empty string '''
- 5 OVER % IF 0 == DO "Buzz" ELSE "" END
- ''' push string "Fizz" if inc. is divisible by 3, else an empty string '''
- OVER 3 SWAP % IF 0 == DO "Fizz" ELSE "" END
- ''' concat the two strings and copy the inc., if the string is empty, swap them '''
- ++ OVER SWAP IF DUP "" == DO SWAP END
- ''' print the top of the stack, drop the next item, add 1 to inc. '''
- . DROP 1 +
+PROC MAIN
+ ''' bottom of the stack is the incrementing value, starts at 1 '''
+ 1
+ ''' while the incrementing value is <= 100 '''
+ WHILE 100 OVER <= DO
+ ''' push string "Buzz" if inc. is divisible by 5, else an empty string '''
+ 5 OVER % IF 0 == DO "Buzz" ELSE "" END
+ ''' push string "Fizz" if inc. is divisible by 3, else an empty string '''
+ OVER 3 SWAP % IF 0 == DO "Fizz" ELSE "" END
+ ''' concat the two strings and copy the inc., if the string is empty, swap them '''
+ ++ OVER SWAP IF DUP "" == DO SWAP END
+ ''' print the top of the stack, drop the next item, add 1 to inc. '''
+ . DROP 1 +
+ END
END
-