FizzBuzz in Haskell
✓ Published0🌍 Public
PP7h
Last edited Feb 4, 2017
Created on Feb 4, 2017
This example demonstrates the classic FizzBuzz algorithm implemented in Haskell, printing results for numbers 1 through 100 to the console. The code defines three pure functions—`fizzbuzz`, `fizz`, and `buzz`—which use Haskell’s `mod` operator for divisibility checks and string concatenation to build each output line. The `main` function leverages the `mapM_` function with `putStrLn` to sequentially output each line, using a list comprehension to generate the input range. No external libraries are used; the example relies solely on Haskell’s standard Prelude, and it is compiled with GHC as shown in the comments.
AI-generated description