mirror of
https://github.com/KarolS/millfork.git
synced 2024-12-25 06:29:17 +00:00
35 lines
627 B
Plaintext
35 lines
627 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
|
|
}
|
|
|
|
array(stage) stages = [
|
|
stage(divisible3.pointer, "fizz"z),
|
|
stage(divisible5.pointer, "buzz"z)
|
|
]
|
|
|
|
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(' ')
|
|
}
|
|
}
|
|
|