1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-12-25 06:29:17 +00:00
millfork/examples/crossplatform/fizzbuzz2.mfk

35 lines
627 B
Plaintext
Raw Normal View History

2019-07-26 22:58:10 +00:00
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 = [
2019-07-26 23:38:06 +00:00
stage(divisible3.pointer, "fizz"z),
stage(divisible5.pointer, "buzz"z)
2019-07-26 22:58:10 +00:00
]
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
2019-07-26 23:11:46 +00:00
putstrz(stages[s].text)
2019-07-26 22:58:10 +00:00
}
}
if not(printed) {
putword(i)
}
putchar(' ')
}
}