1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-07-06 00:28:55 +00:00
millfork/examples/crossplatform/fizzbuzz2.mfk
2019-07-27 01:38:06 +02:00

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(' ')
}
}