|
|
|
|
|
by chucky
2730 days ago
|
|
The Haskell example is quite similar to the Scala/Rust example as well. I guess you could rewrite the Haskell version to match your Scala version pretty closely as well if you prefer doing the tuple construction and then matching on the tuple, like in your Scala version, instead of doing it directly inside the pattern match. Something like this, with the caveat that I haven't done any proper coding in Haskell in years and I don't have an interpreter installed to verify correctness. fb :: (Integer, Integer) -> String
fb (mod3, mod5)
| (0, 0) = "FizzBuzz"
| (0, _) = "Fizz"
| (_, 0) = "Buzz"
| otherwise = show n
main = putStrLn $ unlines $ map fb $ map (\x -> (x % 3, x % 5)) [1..100]
|
|