Skip to content

Instantly share code, notes, and snippets.

@JIghtuse
Last active August 29, 2015 14:02
Show Gist options
  • Save JIghtuse/5b847f180419ea01dcbf to your computer and use it in GitHub Desktop.
Save JIghtuse/5b847f180419ea01dcbf to your computer and use it in GitHub Desktop.
Haskell FizzBuzz
module Main where
fizzBuzz :: Int -> String
fizzBuzz n
| mod n 15 == 0 = "FizzBuzz"
| mod n 3 == 0 = "Fizz"
| mod n 5 == 0 = "Buzz"
| otherwise = show n
main = do
let myFizzBuzzes = map fizzBuzz [1 .. 100]
fbs <- readFile "FizzBuzzes.txt"
if read fbs == myFizzBuzzes
then putStrLn "Right."
else putStrLn "Not right."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment