Extended examples

This commit is contained in:
2023-10-12 18:53:31 +01:00
parent ce34777555
commit c961506a3a
3 changed files with 18 additions and 2 deletions

View File

@@ -0,0 +1,16 @@
import std::to_string
const fizz_buzz := n => (
(recursive r (i=0) list::cons i $ r (i + 1))
|> list::map (i =>
if i % 15 == 0 then "FizzBuzz"
else if i % 3 == 0 then "Fizz"
else if i % 5 == 0 then "Buzz"
else to_string i
)
|> list::take n
|> list::reduce ((l, r) => l ++ "\n" ++ r)
|> option::unwrap
)
const main := fizz_buzz 100