summaryrefslogtreecommitdiff
path: root/examples/fizzbuzz.dumb
blob: 2ba6033f35b08770fb019fe9eb93f2cb5b4a59e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
''' 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