[Skip To Content]


# fizz buzz in haskell

  1. main = putStrLn ( join ( map fizzbuzz [1..100] ) )
  2. join :: [String] -> String
  3. join [x] = x
  4. join (x:xs) = x ++ "\n" ++ ( join xs )
  5. fizzbuzz :: Integer -> String
  6. fizzbuzz x | ( mod x 15 ) == 0 = "Fizzbuzz"
  7. | ( mod x 3 ) == 0 = "Fizz"
  8. | ( mod x 5 ) == 0 = "Buzz"
  9. | otherwise = show x

And the third (first, second) of my Haskell programs. Fizz Buzz! I deliberately built the string in a different (and probably better) way than 99 bottles.

More about this site...

Last Week’s Top 5 Albums (More »)

  1. Conor OberstConor Oberst
  2. Cruel TownBroder Daniel
  3. Far From the Maddening CrowdsChicane
  4. The Midnight Organ FightFrightened Rabbit
  5. Perfect CureLorraine