21 lines
687 B
Plaintext
21 lines
687 B
Plaintext
is-positive = _ > 0 # equivalent to lam(x): x > 0 end
|
|
|
|
fun fizzbuzz(n :: Number%(is-positive)) -> String:
|
|
doc: ```For positive input which is multiples of three return 'Fizz', for the multiples of five return 'Buzz'.
|
|
For numbers which are multiples of both three and five return 'FizzBuzz'. Otherwise, return the number itself.```
|
|
ask:
|
|
| num-modulo(n, 15) == 0 then: "FizzBuzz"
|
|
| num-modulo(n, 3) == 0 then: "Fizz"
|
|
| num-modulo(n, 5) == 0 then: "Buzz"
|
|
| otherwise: num-to-string(n)
|
|
end
|
|
where:
|
|
fizzbuzz(1) is "1"
|
|
fizzbuzz(101) is "101"
|
|
fizzbuzz(45) is "FizzBuzz"
|
|
fizzbuzz(33) is "Fizz"
|
|
fizzbuzz(25) is "Buzz"
|
|
end
|
|
|
|
range(1, 101).map(fizzbuzz).each(print)
|