mirror of
https://git.sr.ht/~rabbits/uxn
synced 2024-11-16 11:15:06 +00:00
20 lines
647 B
Tal
20 lines
647 B
Tal
( Print the first 30 numbers using the following rules:
|
|
| If n is divisible by 3, print "fizz"
|
|
| If n is divisible by 5, print "buzz"
|
|
| If n is divisible by both, print "fizzbuzz"
|
|
| Else, print the number )
|
|
|
|
@fizzbuzz ( -> )
|
|
#1e00
|
|
&>loop ( length i -- )
|
|
DUP fizz OVR buzz ORA ?{ DUP <dec> }
|
|
#0a18 DEO
|
|
INC GTHk ?&>loop
|
|
POP2 BRK
|
|
|
|
@fizz ( n -- ) #03 DIVk MUL SUB ?{ #01 ;Dict/fizz !<str> } #00 JMP2r
|
|
@buzz ( n -- ) #05 DIVk MUL SUB ?{ #01 ;Dict/buzz !<str> } #00 JMP2r
|
|
@<dec> ( n -- ) DUP #0a DIV /d #0a DIVk MUL SUB &d #30 ADD #18 DEO JMP2r
|
|
@<str> ( s* -- ) LDAk #18 DEO INC2 LDAk ?<str> POP2 JMP2r
|
|
@Dict &fizz "Fizz $1 &buzz "Buzz $1
|
|
|