mirror of
https://github.com/KarolS/millfork.git
synced 2024-12-28 11:31:58 +00:00
42 lines
766 B
Plaintext
42 lines
766 B
Plaintext
|
|
import stdio
|
|
|
|
bool divisible3(byte x) = x %% 3 == 0
|
|
bool divisible5(byte x) = x %% 5 == 0
|
|
|
|
struct stage {
|
|
function.byte.to.bool predicate
|
|
pointer text
|
|
}
|
|
|
|
#if ENCODING_NOLOWER
|
|
array(stage) stages = [
|
|
stage(divisible3.pointer, "FIZZ"z),
|
|
stage(divisible5.pointer, "BUZZ"z)
|
|
]
|
|
#else
|
|
array(stage) stages = [
|
|
stage(divisible3.pointer, "fizz"z),
|
|
stage(divisible5.pointer, "buzz"z)
|
|
]
|
|
#endif
|
|
|
|
void main() {
|
|
byte i, s
|
|
bool printed
|
|
for i,1,to,100 {
|
|
printed = false
|
|
for s,0,until,stages.length {
|
|
if call(stages[s].predicate, i) {
|
|
printed = true
|
|
putstrz(stages[s].text)
|
|
}
|
|
}
|
|
if not(printed) {
|
|
putword(i)
|
|
}
|
|
putchar(' ')
|
|
}
|
|
}
|
|
|