After I had to deal with the fizzbuzz programmer test, I became interested how pattern matching works in Haskell and F#. I found the following solution for Haskell on the web.
{-
- Fizzbuzz, https://wiki.haskell.org/index.php?title=Fizzbuzz&oldid=33893 (last visited January 19, 2020).
-}
fizz n | n `mod` 15 == 0 = "FizzBuzz"
| n `mod` 3 == 0 = "Fizz"
| n `mod` 5 == 0 = "Buzz"
| otherwise = show n
main = mapM_ putStrLn $ map fizz [1..16]
And the following solution for F#.
// https://fsharpforfunandprofit.com/posts/match-expression/
let fizzBuzz number =
match number with
| i when i % 15 = 0 -> printfn "fizzbuzz"
| i when i % 3 = 0 -> printfn "fizz"
| i when i % 5 = 0 -> printfn "buzz"
| i -> printfn "%i" i
[1..16] |> List.iter fizzBuzz
As I am no expert in these languages, I have no idea if those solutions are elegant or not. I just had a look at them to compare the different implementations. Please have a look at the web sites to find out more.