September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
16
Task/FizzBuzz/Dc/fizzbuzz-1.dc
Normal file
16
Task/FizzBuzz/Dc/fizzbuzz-1.dc
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
[[Fizz]P 1 sw]sF
|
||||
[[Buzz]P 1 sw]sB
|
||||
[li p sz]sN
|
||||
[[
|
||||
]P]sW
|
||||
[
|
||||
0 sw [w = 0]sz
|
||||
li 3 % 0 =F [Fizz if 0 == i % 3]sz
|
||||
li 5 % 0 =B [Buzz if 0 == i % 5]sz
|
||||
lw 0 =N [print Number if 0 == w]sz
|
||||
lw 1 =W [print neWline if 1 == w]sz
|
||||
li 1 + si [i += 1]sz
|
||||
li 100 !<L [continue Loop if 100 >= i]sz
|
||||
]sL
|
||||
1 si [i = 1]sz
|
||||
0 0 =L [enter Loop]sz
|
||||
18
Task/FizzBuzz/Dc/fizzbuzz-2.dc
Normal file
18
Task/FizzBuzz/Dc/fizzbuzz-2.dc
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# dc is stack based, so we use the stack instead of a variable for our
|
||||
# current number.
|
||||
|
||||
1 # Number = 1
|
||||
[[Fizz]n 1 sw]sF # Prints "Fizz" prevents Number from printing
|
||||
[[Buzz]n 1 sw]sB # Prints "Buzz" prevents Number from printing
|
||||
[dn]sN # Prints Number
|
||||
[
|
||||
dd # Put two extra copies of Number on stack
|
||||
0 sw # w = 0
|
||||
3% 0=F # Fizz if 0 == Number % 3 (destroys 1st copy)
|
||||
5% 0=B # Buzz if 0 == Number % 5 (destroys 2nd copy)
|
||||
lw 0=N # Print Number if 0 == w
|
||||
[
|
||||
]n # Print new line
|
||||
1+d # Number += 1 and put extra copy on stack
|
||||
100!<L # Continue Loop if 100 >= Number (destroys copy)
|
||||
]dsLx # Enter Loop
|
||||
Loading…
Add table
Add a link
Reference in a new issue